diff --git a/src/components/tree/node.vue b/src/components/tree/node.vue index 21e6620..2029bba 100644 --- a/src/components/tree/node.vue +++ b/src/components/tree/node.vue @@ -17,11 +17,12 @@ {{ data.title }} + :show-checkbox="showCheckbox" + :children-key="childrenKey"> @@ -52,6 +53,10 @@ type: Boolean, default: false }, + childrenKey: { + type: String, + default: 'children' + }, showCheckbox: { type: Boolean, default: false @@ -93,7 +98,7 @@ ]; }, showArrow () { - return (this.data.children && this.data.children.length) || ('loading' in this.data && !this.data.loading); + return (this.data[this.childrenKey] && this.data[this.childrenKey].length) || ('loading' in this.data && !this.data.loading); }, showLoading () { return 'loading' in this.data && this.data.loading; @@ -118,6 +123,9 @@ } else { return []; } + }, + children () { + return this.data[this.childrenKey]; } }, methods: { @@ -126,14 +134,14 @@ if (item.disabled) return; // async loading - if (item.children.length === 0) { + if (item[this.childrenKey].length === 0) { const tree = findComponentUpward(this, 'Tree'); if (tree && tree.loadData) { this.$set(this.data, 'loading', true); tree.loadData(item, children => { this.$set(this.data, 'loading', false); if (children.length) { - this.$set(this.data, 'children', children); + this.$set(this.data, this.childrenKey, children); this.$nextTick(() => this.handleExpand()); } }); @@ -141,7 +149,7 @@ } } - if (item.children && item.children.length) { + if (item[this.childrenKey] && item[this.childrenKey].length) { this.$set(this.data, 'expand', !this.data.expand); this.dispatch('Tree', 'toggle-expand', this.data); } diff --git a/src/components/tree/tree.vue b/src/components/tree/tree.vue index 1da8e2f..ac4c381 100644 --- a/src/components/tree/tree.vue +++ b/src/components/tree/tree.vue @@ -6,7 +6,8 @@ :data="item" visible :multiple="multiple" - :show-checkbox="showCheckbox"> + :show-checkbox="showCheckbox" + :children-key="childrenKey">
{{ localeEmptyText }}
@@ -40,6 +41,10 @@ emptyText: { type: String }, + childrenKey: { + type: String, + default: 'children' + }, loadData: { type: Function }, -- libgit2 0.21.4