提问
问题描述:
老师,这里报错提示传入的shopId是常量?
相关截图:
相关代码:
import { createStore } from "vuex";
export default createStore({
state: {
cartList: {},
},
mutations: {
ChangeCartItemInfo(state, payload) {
const { shopId, productId, productInfo, num } = payload;
let shopInfo = state.cartList[shopId];
if (!shopInfo) {
shopId = {};
}
let product = shopInfo[productId];
if (!productInfo) {
product = productInfo;
product.count = 0;
}
product.count = product.count + num;
if (product.count < 0) {
product.count = 0;
} else if (product.count > 99) {
product.count = 99;
}
shopInfo[productId] = product;
state.cartList[shopId] = shopInfo;
},
},
actions: {},
modules: {},
});
11
收起
正在回答 回答被采纳积分+1
2回答
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星