Skip to content

Commit

Permalink
fix(tree-select): fix data lazy load bug
Browse files Browse the repository at this point in the history
  • Loading branch information
PengYYYYY committed Dec 30, 2021
1 parent 18b1888 commit 797f8a7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/tree-select/tree-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default defineComponent({
actived: [],
expanded: [],
nodeInfo: null,
treeKey: 0,
};
},
computed: {
Expand Down Expand Up @@ -215,6 +216,10 @@ export default defineComponent({
this.actived = this.nodeInfo ? [this.nodeInfo.value] : [];
}
},
async data() {
await this.changeNodeInfo();
this.treeRerender();
},
},
async mounted() {
if (!this.value && this.defaultValue) {
Expand Down Expand Up @@ -349,9 +354,12 @@ export default defineComponent({
this.nodeInfo = null;
}
},
treeRerender() {
this.treeKey += 1;
},
},
render(): VNode {
const { treeProps, popupObject, classes, popupClass } = this;
const { treeProps, popupObject, classes, popupClass, treeKey } = this;
const iconStyle = { 'font-size': this.size };
const treeSlots = {
empty: () => <>{this.emptySlot}</>,
Expand All @@ -360,6 +368,7 @@ export default defineComponent({
<tree
ref="tree"
v-show={this.showTree}
key={treeKey}
value={this.checked}
hover
expandAll
Expand Down

0 comments on commit 797f8a7

Please sign in to comment.