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
+37 -5
View File
@@ -17,7 +17,7 @@ Vue.use(TreeSelect);
<van-tree-select
:items="items"
:active-id.sync="activeId"
:main-active-index.sync="mainActiveIndex"
:main-active-index.sync="activeIndex"
/>
```
@@ -27,7 +27,7 @@ export default {
return {
items,
activeId: 1,
mainActiveIndex: 0
activeIndex: 0
};
}
}
@@ -39,7 +39,7 @@ export default {
<van-tree-select
:items="items"
:active-id.sync="activeIds"
:main-active-index.sync="mainActiveIndex"
:main-active-index.sync="activeIndex"
/>
```
@@ -49,12 +49,44 @@ export default {
return {
items,
activeIds: [1, 2],
mainActiveIndex: 0
activeIndex: 0
};
}
}
```
### Custom 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: 'Group 1' }, { text: 'Group 2' }]
}
}
}
```
## API
### Props
@@ -89,7 +121,7 @@ In every tree object, `text` property defines `id` stands for the unique key whi
[
{
// name of the parent node
text: 'All Cities',
text: 'Group 1',
// leaves of this parent node
children: [
{