From 0afa0bb1651676fcdf3ca52a4e52a5384fa4b25d Mon Sep 17 00:00:00 2001 From: puhui999 Date: Thu, 20 Feb 2025 16:57:35 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=BC=BA=E9=99=B7=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E3=80=91IoT:=20=E7=89=A9=E6=A8=A1=E5=9E=8B=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E6=B7=BB=E5=8A=A0=E7=9A=84=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E4=BD=93=EF=BC=8C=E9=87=8C=E9=9D=A2=E7=9A=84=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=8A=A0=E4=B8=8D=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataSpecs/ThingModelStructDataSpecs.vue | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/views/iot/thingmodel/dataSpecs/ThingModelStructDataSpecs.vue b/src/views/iot/thingmodel/dataSpecs/ThingModelStructDataSpecs.vue index 6088743a..fb2258c1 100644 --- a/src/views/iot/thingmodel/dataSpecs/ThingModelStructDataSpecs.vue +++ b/src/views/iot/thingmodel/dataSpecs/ThingModelStructDataSpecs.vue @@ -5,7 +5,6 @@ :rules="[{ required: true, validator: validateList, trigger: 'change' }]" label="JSON 对象" > -
{ } // 查找是否已有相同 identifier 的项 - if (isEmpty(dataSpecsList.value)) { - dataSpecsList.value = [] - } const existingIndex = dataSpecsList.value.findIndex( (spec) => spec.identifier === data.identifier ) @@ -158,6 +154,13 @@ const validateList = (_: any, __: any, callback: any) => { } callback() } + +/** 组件初始化 */ +onMounted(async () => { + await nextTick() + // 预防 dataSpecsList 空指针 + isEmpty(dataSpecsList.value) && (dataSpecsList.value = []) +})