export default new Vuex.Store({
state: {
shoplist: [], //购物车的数据
},
mutations: {
// 加入购物车 如果已有商品 数量++
Btnshop(state, val) {
let finfindex = state.shoplist.findIndex(item => item.id == val.id)
if (finfindex === -1) {
state.shoplist.push(val)
} else {
state.shoplist[finfindex].num++
}
},
},
actions: {
},
modules: {
},
plugins: [persiste()]
})