From 797f8a7076f3bb209a41ab8c1fbbdc8ed8023b8b Mon Sep 17 00:00:00 2001 From: pengYYY Date: Thu, 30 Dec 2021 14:46:33 +0800 Subject: [PATCH] fix(tree-select): fix data lazy load bug --- src/tree-select/tree-select.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/tree-select/tree-select.tsx b/src/tree-select/tree-select.tsx index 3b969179c0..cdedb70162 100644 --- a/src/tree-select/tree-select.tsx +++ b/src/tree-select/tree-select.tsx @@ -59,6 +59,7 @@ export default defineComponent({ actived: [], expanded: [], nodeInfo: null, + treeKey: 0, }; }, computed: { @@ -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) { @@ -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}, @@ -360,6 +368,7 @@ export default defineComponent({