From aa68c01ace60805dc201f3b5eae7b1742d7fe187 Mon Sep 17 00:00:00 2001
From: lifizer <913626195@qq.com>
Date: Mon, 23 Sep 2024 11:52:13 +0800
Subject: [PATCH] =?UTF-8?q?Fix(=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85):[#229?=
=?UTF-8?q?7]=E6=97=A0=E6=95=88=E7=9A=84=E8=A7=84=E6=A0=BC=EF=BC=8C?=
=?UTF-8?q?=E4=BB=8D=E7=84=B6=E5=8F=AF=E4=BB=A5=E7=82=B9=E5=87=BB=EF=BC=8C?=
=?UTF-8?q?=E5=B9=B6=E4=B8=94=E6=9C=AA=E6=98=BE=E7=A4=BA=E4=BB=B7=E6=A0=BC?=
=?UTF-8?q?=EF=BC=8C=E5=BA=93=E5=AD=98=E6=98=BE=E7=A4=BAundefined?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/ProductWindow.vue | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/components/ProductWindow.vue b/components/ProductWindow.vue
index d489b70..7726c75 100644
--- a/components/ProductWindow.vue
+++ b/components/ProductWindow.vue
@@ -42,10 +42,7 @@
购买数量
-
- {{ cartNum }}
+ {{ cartNum }}
{}
+ default: () => {
+ return {
+ productAttr: []
+ }
+ }
},
// 使用字符串再转成对象的原因是,当key='2.5g'时,会变成key='2',导致数据丢失
productValueStr: {
@@ -102,12 +103,18 @@ export default {
this.$emit("changeFun", { action: "ChangeCartNum", value: 1 })
},
getAttrItemData(attr) {
- let result = {}
- this.productValueArr.map(item => {
- if (item.attrItemkey === attr) {
- result = item
- }
- })
+ let result = {
+ stock: 0
+ }
+ if (this.attr.productAttr.length === 1) {
+ this.productValueArr.map(item => {
+ if (item.attrItemkey === attr) {
+ result = item
+ }
+ })
+ } else {
+ result.stock = 1
+ }
return result
},
tapAttr: function(indexw, indexn, itemn) {