From 31b22e7225fd1cf5b4a6bd306dc39979d1d3db49 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Thu, 4 Jun 2026 10:02:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(diy-group):=20=E4=BF=AE=E5=A4=8D=E9=A1=B6?= =?UTF-8?q?=E9=83=A8=E5=AF=BC=E8=88=AA=E9=A2=9C=E8=89=B2=E5=92=8C=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=A0=B7=E5=BC=8F=E8=AE=A1=E7=AE=97=E7=9A=84=E7=A9=BA?= =?UTF-8?q?=E5=80=BC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为topNavColor计算属性增加diyData和global字段的空值校验,防止访问undefined属性报错;同时在setPagestyle方法开头增加diyGlobalData的空值判断,避免遍历失败 --- components-diy/diy-group.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components-diy/diy-group.vue b/components-diy/diy-group.vue index df2552e..ea13772 100644 --- a/components-diy/diy-group.vue +++ b/components-diy/diy-group.vue @@ -300,20 +300,21 @@ export default { computed: { topNavColor() { var color = ''; - if (this.diyData.global.topNavBg) { + if (this.diyData && this.diyData.global && this.diyData.global.topNavBg) { color = 'transparent'; if (this.scrollTop > 20) { color = this.diyData.global.topNavColor; } else { color = 'transparent'; } - } else { + } else if (this.diyData && this.diyData.global) { color = this.diyData.global.topNavColor; } return color; }, // 修改属性样式 setPagestyle() { + if (!this.diyGlobalData || !this.diyGlobalData.value) return []; this.diyGlobalData.value.forEach((item, index) => { item.pageStyle = ''; // 给每个组件增加位置属性,用于定位,搜索、分类导航等定位