docs(TreeSelect): add custom content demo (#4272)

This commit is contained in:
neverland
2019-08-28 15:09:18 +08:00
committed by GitHub
parent ac193fef3c
commit 9c68de0d88
6 changed files with 252 additions and 146 deletions
+38 -4
View File
@@ -19,7 +19,7 @@ Vue.use(TreeSelect);
<van-tree-select
:items="items"
:active-id.sync="activeId"
:main-active-index.sync="mainActiveIndex"
:main-active-index.sync="activeIndex"
/>
```
@@ -29,7 +29,7 @@ export default {
return {
items,
activeId: 1,
mainActiveIndex: 0
activeIndex: 0
};
}
}
@@ -43,7 +43,7 @@ export default {
<van-tree-select
:items="items"
:active-id.sync="activeIds"
:main-active-index.sync="mainActiveIndex"
:main-active-index.sync="activeIndex"
/>
```
@@ -53,12 +53,46 @@ export default {
return {
items,
activeIds: [1, 2],
mainActiveIndex: 0
activeIndex: 0
};
}
}
```
### 自定义内容
通过`content`插槽可以自定义右侧区域的内容
```html
<van-tree-select
height="55vw"
:items="items"
:main-active-index.sync="activeIndex"
>
<template slot="content">
<van-image
v-if="activeIndex === 0"
src="https://img.yzcdn.cn/vant/apple-1.jpg"
/>
<van-image
v-if="activeIndex === 1"
src="https://img.yzcdn.cn/vant/apple-2.jpg"
/>
</template>
</van-tree-select>
```
```js
export default {
data() {
return {
activeIndex: 0,
items: [{ text: '分组 1' }, { text: '分组 2' }]
}
}
}
```
## API
### Props