From 076310a789a13e352d1d9b76e3d75294afc19466 Mon Sep 17 00:00:00 2001 From: Stephen Ma Date: Fri, 7 Feb 2020 14:28:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E6=9C=80=E5=90=8E?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E8=8A=82=E7=82=B9=E6=97=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 例子:https://www.iviewui.com/components/tree#ZDYJDNR,删除最后一个节点时,控制台报错,找不到节点,因为被删除了。 --- src/components/tree/tree.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/tree/tree.vue b/src/components/tree/tree.vue index 9ee99fda..97b7c6d8 100644 --- a/src/components/tree/tree.vue +++ b/src/components/tree/tree.vue @@ -171,6 +171,7 @@ } }, handleSelect (nodeKey) { + if (!this.flatState[nodeKey]) return const node = this.flatState[nodeKey].node; if (!this.multiple){ // reset previously selected node const currentSelectedKey = this.flatState.findIndex(obj => obj.node.selected); @@ -181,6 +182,7 @@ this.$emit('on-select-change', this.getSelectedNodes(), node); }, handleCheck({ checked, nodeKey }) { + if (!this.flatState[nodeKey]) return const node = this.flatState[nodeKey].node; this.$set(node, 'checked', checked); this.$set(node, 'indeterminate', false);