diff --git a/src/tree-select/README.md b/src/tree-select/README.md index e36bb87ce..2078ac4d6 100644 --- a/src/tree-select/README.md +++ b/src/tree-select/README.md @@ -17,7 +17,7 @@ Vue.use(TreeSelect); ``` @@ -27,7 +27,7 @@ export default { return { items, activeId: 1, - mainActiveIndex: 0 + activeIndex: 0 }; } } @@ -39,7 +39,7 @@ export default { ``` @@ -49,12 +49,44 @@ export default { return { items, activeIds: [1, 2], - mainActiveIndex: 0 + activeIndex: 0 }; } } ``` +### Custom Content + +```html + + + +``` + +```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: [ { diff --git a/src/tree-select/README.zh-CN.md b/src/tree-select/README.zh-CN.md index c506f31f0..352bbcaf7 100644 --- a/src/tree-select/README.zh-CN.md +++ b/src/tree-select/README.zh-CN.md @@ -19,7 +19,7 @@ Vue.use(TreeSelect); ``` @@ -29,7 +29,7 @@ export default { return { items, activeId: 1, - mainActiveIndex: 0 + activeIndex: 0 }; } } @@ -43,7 +43,7 @@ export default { ``` @@ -53,12 +53,46 @@ export default { return { items, activeIds: [1, 2], - mainActiveIndex: 0 + activeIndex: 0 }; } } ``` +### 自定义内容 + +通过`content`插槽可以自定义右侧区域的内容 + +```html + + + +``` + +```js +export default { + data() { + return { + activeIndex: 0, + items: [{ text: '分组 1' }, { text: '分组 2' }] + } + } +} +``` + ## API ### Props diff --git a/src/tree-select/demo/data.en-US.ts b/src/tree-select/demo/data.en-US.ts new file mode 100644 index 000000000..beddfe1a1 --- /dev/null +++ b/src/tree-select/demo/data.en-US.ts @@ -0,0 +1,66 @@ +const group1 = [ + { + text: 'Delaware', + id: 1 + }, + { + text: 'Florida', + id: 2 + }, + { + text: 'Georqia', + id: 3, + disabled: true + }, + { + text: 'Indiana', + id: 4 + } +]; + +const group2 = [ + { + text: 'Alabama', + id: 5 + }, + { + text: 'Kansas', + id: 6 + }, + { + text: 'Louisiana', + id: 7 + }, + { + text: 'Texas', + id: 8 + } +]; + +const group3 = [ + { + text: 'Alabama', + id: 9 + }, + { + text: 'Kansas', + id: 10 + } +]; + + +export const enUSData = [ + { + text: 'Group 1', + children: group1 + }, + { + text: 'Group 2', + children: group2 + }, + { + text: 'Group 3', + disabled: true, + children: group3 + } +]; diff --git a/src/tree-select/demo/data.zh-CN.ts b/src/tree-select/demo/data.zh-CN.ts new file mode 100644 index 000000000..b2c8789cf --- /dev/null +++ b/src/tree-select/demo/data.zh-CN.ts @@ -0,0 +1,65 @@ +const zhejiang = [ + { + text: '杭州', + id: 1 + }, + { + text: '温州', + id: 2 + }, + { + text: '宁波', + id: 3, + disabled: true + }, + { + text: '义乌', + id: 4 + } +]; + +const jiangsu = [ + { + text: '南京', + id: 5 + }, + { + text: '无锡', + id: 6 + }, + { + text: '徐州', + id: 7 + }, + { + text: '苏州', + id: 8 + } +]; + +const fujian = [ + { + text: '泉州', + id: 9 + }, + { + text: '厦门', + id: 10 + } +]; + +export const zhCNData = [ + { + text: '浙江', + children: zhejiang + }, + { + text: '江苏', + children: jiangsu + }, + { + text: '福建', + disabled: true, + children: fujian + } +]; diff --git a/src/tree-select/demo/index.vue b/src/tree-select/demo/index.vue index 90ca17fc8..ae8071c7e 100644 --- a/src/tree-select/demo/index.vue +++ b/src/tree-select/demo/index.vue @@ -4,7 +4,7 @@ @@ -12,157 +12,61 @@ + + + + + +