@@ -171,28 +171,46 @@ const pagination = (value) => {
};
function addIsCheckProperty(data) {
+ if (!data) return;
+
if (Array.isArray(data)) {
data.forEach((item) => {
- item.ischeck = false; // 为当前层级添加属性
- if (item.cartDetails) {
- // 处理子集
- addIsCheckProperty(item.cartDetails);
- }
- if (item.records) {
- // 处理父级(如存在嵌套结构)
- addIsCheckProperty(item.records);
- }
+ item.ischeck = false;
+ // 只处理明确知道的嵌套属性,避免无限递归
+ item.cartDetails && addIsCheckProperty(item.cartDetails);
+ item.records && addIsCheckProperty(item.records);
});
- } else if (typeof data === 'object' && data !== null) {
+ } else if (typeof data === 'object') {
data.ischeck = false;
- for (let key in data) {
- if (typeof data[key] === 'object') {
- addIsCheckProperty(data[key]); // 递归处理嵌套对象
- }
- }
+ // 不自动遍历所有属性,只处理已知的特定属性
+ data.cartDetails && addIsCheckProperty(data.cartDetails);
+ data.records && addIsCheckProperty(data.records);
}
}
+// function addIsCheckProperty(data) {
+// if (Array.isArray(data)) {
+// data.forEach((item) => {
+// item.ischeck = false; // 为当前层级添加属性
+// if (item.cartDetails) {
+// // 处理子集
+// addIsCheckProperty(item.cartDetails);
+// }
+// if (item.records) {
+// // 处理父级(如存在嵌套结构)
+// addIsCheckProperty(item.records);
+// }
+// });
+// } else if (typeof data === 'object' && data !== null) {
+// data.ischeck = false;
+// for (let key in data) {
+// if (typeof data[key] === 'object') {
+// addIsCheckProperty(data[key]); // 递归处理嵌套对象
+// }
+// }
+// }
+// }
+
const numberChange = (value, index, indexg) => {
console.log(value, index, indexg);
setGoodsCount({ goodsId: data.value[index].cartDetails[indexg].id, count: value });
@@ -612,6 +630,7 @@ function removeCheckedItems(data) {
}
.price {
font-weight: 400;
+ width: 200px;
}
.total {
font-weight: 700;
@@ -623,6 +642,7 @@ function removeCheckedItems(data) {
.good-del {
font-size: 16px;
color: $color-999;
+ width: 44px;
}
}
}