From 0aea3f94c7c2fa6637076a7c47302297a2aedf7e Mon Sep 17 00:00:00 2001 From: From-wh Date: Wed, 21 Oct 2026 11:44:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=AE=A1=E7=90=86=E7=AB=AFDIY):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E9=A3=8E?= =?UTF-8?q?=E6=A0=BC=E9=80=89=E6=8B=A9=E9=9D=A2=E6=9D=BF=E7=A9=BA=E7=99=BD?= =?UTF-8?q?=E4=B8=8E=E9=80=9A=E7=94=A8=E6=A0=B7=E5=BC=8F=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mobileConfig/c_home_goods_list.vue | 31 ++++++++----------- .../mobileConfigRight/c_card_select.vue | 8 +++-- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/frontend/admin/src/diy/components/mobileConfig/c_home_goods_list.vue b/frontend/admin/src/diy/components/mobileConfig/c_home_goods_list.vue index d0af5e086..c9f6a4b38 100644 --- a/frontend/admin/src/diy/components/mobileConfig/c_home_goods_list.vue +++ b/frontend/admin/src/diy/components/mobileConfig/c_home_goods_list.vue @@ -361,11 +361,14 @@ watch( () => configObj.value?.toneCartConfig?.tabVal, (nVal, oVal) => { type5 = nVal; + // arr 须与其余 watcher 保持一致(勿插入 titleLeft 标题): + // rCom 按 index 复用 key,此处多插一项会使后续控件全部错位重挂载, + // 顶部「选择风格」卡片(c_card_select)会因无初始化而渲染为空白 var arr = [ - { - components: toolCom.c_title, - configNme: 'titleLeft', - }, + // { + // components: toolCom.c_title, + // configNme: 'titleLeft', + // }, { components: toolCom.c_card_select, configNme: 'styleConfig', @@ -461,27 +464,19 @@ function getRComContent(arr, type, type2, type3) { } } function getRComStyle(arr, type, type3, type4, type5) { - let obj4 = [], - currencyStyle = []; + let obj4 = []; + // 通用样式取模块级 currencyStyle(原 Vue2 为 [...this.currencyStyle]); + // 勿在函数内再声明同名局部变量,否则遮蔽后自展开空数组,样式设置页会丢失整个通用样式区 + const commonStyle = [...currencyStyle]; if (type4) { if (type == 1 || type == 4) { obj4 = [...oneStyle1, ...oneStyle2]; - currencyStyle = [...currencyStyle]; } else if (type == 0) { obj4 = [...oneStyle1, ...oneStyle2, ...oneStyle3]; - currencyStyle = [...currencyStyle]; } else if (type == 2 || type == 3) { obj4 = [...oneStyle1]; - currencyStyle = [...currencyStyle]; } else { obj4 = [...oneStyle1, ...oneStyle2]; - currencyStyle = [...currencyStyle]; - } - } else { - if (type == 0 || type == 1 || type == 4) { - currencyStyle = [...currencyStyle]; - } else { - currencyStyle = [...currencyStyle]; } } let obj5 = []; @@ -493,9 +488,9 @@ function getRComStyle(arr, type, type3, type4, type5) { } } if (type3 == 0) { - rCom.value = [...arr, ...oneStyle, ...obj4, ...obj5, ...currencyStyle]; + rCom.value = [...arr, ...oneStyle, ...obj4, ...obj5, ...commonStyle]; } else { - rCom.value = [...arr, ...oneStyle, ...obj4, ...currencyStyle]; + rCom.value = [...arr, ...oneStyle, ...obj4, ...commonStyle]; } } function getConfig(data, name) { diff --git a/frontend/admin/src/diy/components/mobileConfigRight/c_card_select.vue b/frontend/admin/src/diy/components/mobileConfigRight/c_card_select.vue index 87dbc521c..38d172925 100644 --- a/frontend/admin/src/diy/components/mobileConfigRight/c_card_select.vue +++ b/frontend/admin/src/diy/components/mobileConfigRight/c_card_select.vue @@ -45,10 +45,12 @@ const configData = ref({}); watch( () => props.configObj, (nVal) => { - defaults.value = nVal; - configData.value = nVal[props.configNme]; + defaults.value = nVal || {}; + // 配置面板 rCom 按 index 复用 key,条目插入/移出会使本组件重挂载, + // 必须 immediate 初始化(挂载时 props 已就绪),否则卡片渲染为空白、样式切换丢失 + configData.value = nVal?.[props.configNme] || {}; }, - { deep: true }, + { immediate: true, deep: true }, ); function handleSelect(index) {