Skip to content

Commit 92db219

Browse files
committed
<add>(index-list.doc): custom item slot
1 parent 59ef83f commit 92db219

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

document/components/docs/zh-CN/index-list.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,82 @@
6262
}
6363
}
6464
```
65+
66+
- 自定义插槽
67+
68+
除了默认结构,你还可以根据自己的需要自定义每一项的内容。如下所示,将你的自定义内容项填入`cube-index-list-item`的插槽。除非你真的知道自己在做什么,否则不要修改`cube-index-list-group``cube-index-list-item`的用法。
69+
70+
```html
71+
<cube-index-list :data="cityData">
72+
<cube-index-list-group
73+
v-for="(group, index) in cityData"
74+
:key="index"
75+
:group="group">
76+
<cube-index-list-item
77+
v-for="(item, index) in group.items"
78+
:key="index"
79+
:item="item"
80+
@select="selectItem">
81+
<div class="custom-item">我是自定义 {{item.name}}</div>
82+
</cube-index-list-item>
83+
</cube-index-list-group>
84+
</cube-index-list>
85+
```
86+
```javascript
87+
export default {
88+
data() {
89+
return {
90+
cityData: cityData
91+
}
92+
},
93+
methods: {
94+
selectItem(item) {
95+
console.log(item.name)
96+
},
97+
clickTitle(title) {
98+
console.log(title)
99+
}
100+
}
101+
}
102+
```
103+
```stylus
104+
// 自定义项的样式
105+
.custom-item
106+
position: relative
107+
height: 70px
108+
line-height: 70px
109+
padding: 0 16px
110+
font-size: $fontsize-medium
111+
112+
// 用自定义样式,覆写内置的默认样式
113+
.cube-index-list-content
114+
background-color: #222
115+
color: #909090
116+
.cube-index-list-anchor
117+
background-color: #333
118+
height: 30px
119+
line-height: 30px
120+
padding: 0 0 0 20px
121+
.cube-index-list-nav
122+
padding: 20px 0
123+
border-radius: 10px
124+
background: rgba(0,0,0,.3)
125+
>ul
126+
>li
127+
padding: 3px
128+
font-size: 12px
129+
color: #909090
130+
&.active
131+
color: #ffcd32
132+
```
65133

66134
### Props 配置
67135

68136
| 参数 | 说明 | 类型 | 默认值 |
69137
| - | - | - | - |
70138
| title | 标题 | String | - |
71139
| data | 需要展示的数据 | Array | [] |
140+
| speed | 点击导航栏索引时,滚动到相应位置的动画时间(单位:ms) | number | 300 |
72141

73142
- `data` 子配置项
74143

0 commit comments

Comments
 (0)