From b70b3a40df8ef6363c4a92431342a41708bc385f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B5=B5=E6=AF=85?= <1335909236@qq.com>
Date: Sat, 6 Sep 2025 10:09:44 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=98=93=E8=B4=AD=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2=E9=80=89=E6=8B=A9=E8=A7=84=E6=A0=BC=E6=8C=89=E9=92=AE?=
=?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91=E9=94=99=E8=AF=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
packages/shop/index/index.vue | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/packages/shop/index/index.vue b/packages/shop/index/index.vue
index 9d31b27a..9d6af476 100644
--- a/packages/shop/index/index.vue
+++ b/packages/shop/index/index.vue
@@ -135,14 +135,14 @@
-
选择规格
-
收起
@@ -338,17 +338,22 @@ export default {
this.topShow = !this.topShow;
},
// 选择商品规格
- chooseGG(targetItems) {
- // 遍历tagList找到目标对象(排除"全部"选项,从索引1开始)
- for (let i = 1; i < this.tagList.length; i++) {
- const tagItem = this.tagList[i];
- const infoIndex = tagItem.commodity_info_list.findIndex(item => item.id === targetItems.id);
- if (infoIndex > -1) {
- // 直接修改数据源中的对象,确保响应式
- const currentItem = tagItem.commodity_info_list[infoIndex];
- this.$set(currentItem, 'isShow', !currentItem.isShow);
- console.log("修改后数据源中的isShow:", currentItem.isShow);
- break;
+ chooseGG(item,targetItems) {
+ // 根据两个参数的id判断点击的数据
+ if (item && targetItems && item.id) {
+ for (let i = 1; i < this.tagList.length; i++) {
+ const tagItem = this.tagList[i];
+ // 先根据item.id找到对应的tagItem
+ if (tagItem.id === item.id) {
+ const infoIndex = tagItem.commodity_info_list.findIndex(infoItem => infoItem.id === targetItems.id);
+ if (infoIndex > -1) {
+ // 直接修改数据源中的对象,确保响应式
+ const currentItem = tagItem.commodity_info_list[infoIndex];
+ this.$set(currentItem, 'isShow', !currentItem.isShow);
+ console.log("修改后数据源中的isShow:", currentItem.isShow);
+ break;
+ }
+ }
}
}
},