From a36215bda20a2fcdd9dca6c7befc5ffd8dbb2946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jingyu=20Feng=28=E5=86=AF=E7=BB=8F=E5=AE=87=29?= <244202969@qq.com> Date: Fri, 7 May 2021 15:20:43 +0800 Subject: [PATCH] Fix bug --- terraform-ui/src/pages/components/tree.vue | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/terraform-ui/src/pages/components/tree.vue b/terraform-ui/src/pages/components/tree.vue index 52a614a7..af7d38a2 100644 --- a/terraform-ui/src/pages/components/tree.vue +++ b/terraform-ui/src/pages/components/tree.vue @@ -232,10 +232,15 @@ export default { let attr = attrs.slice(0, attrs.length - 1) let copyData = this.renderValue(this.jsonJ, attr) if (Object.keys(copyData).length === 1) { - let attr2 = attrs.slice(0, attrs.length - 2) - let copyData2 = this.renderValue(this.jsonJ, attr2) - const key = attr.slice(-1)[0] - copyData2[key] = '' + // 只剩一个母节点情况 + if (attrs.length === 1) { + this.jsonJ = {} + } else { + let attr2 = attrs.slice(0, attrs.length - 2) + let copyData2 = this.renderValue(this.jsonJ, attr2) + const key = attr.slice(-1)[0] + copyData2[key] = '' + } } else { delete copyData[data.key] }