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) {