vue中提示goods. forEach is not function,如何解决哈
代码粘出来哈
let footerCart={
template:"#footerCart",
computed:{
totalPrice(){
return this.$store.getters.totalPrice
}
}
}
let Lists = {
template: '#Lists',
computed: {
/* totalPrice() {
return this.$store.getters.totalPrice
},*/
goods() {
return this.$store.getters.goods;
}
},
methods: {
del(id) {
this.$store.commit('del', { id })
}
}
}
let store = new Vuex.Store({
state: {
goods:[]
},
getters: {
//获取商品总价
totalPrice: state => {
let totalPrice = 0;
state.goods.forEach((v) => {
totalPrice += v.num * v.price;
})
return totalPrice;
},
/*totalPrice:function(state){}*/
//获取商品并计算每件商品的总价
goods(state) {
let goods = state.goods;
goods.forEach((v) => {
v.totalPrice = v.num * v.price;
});
return goods;
}
},
mutations: {
del(state, param) {
console.log(param);
let k;
for(var i=0;i |
免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。
版权声明:作者保留权利,不代表本站立场。
|
|
|
|
|
|
|
|
vuex中actions及axios结合使用的时候,遇到的问题,希望路过的大神指点一下哈,谢谢 |
|
|
|
|
|
|
|