computed: {
sumPrice() {
return this.list
.filter(item => !!item.quantity)
.reduce((prev, cur) => {
if (cur.deposit > 0) return prev + cur.deposit * cur.quantity
return prev
}, 0).toFixed(2)
}
},
onLoad(options) {
this.isRelaunch = options.isRelaunch
this.workBorrowGoods = JSON.parse(uni.$storge.workBorrowGoods)
this.getList()
},
methods:{
//物品列表
getList(){
goodsList().then(res=>{
this.list = res.data;
if(this.isRelaunch){
this.list.filter(item=>{
this.workBorrowGoods.find(every=>{
if(item.id == every.goodsId){
//item.quantity = every.goodsNumber 错误写法
//需要使用this.$set 触发更新
this.$set(item,'quantity',every.goodsNumber)
}
})
})
}
})
},
}
vue computed,对象里的一个数组属性变了,不会执行
最新推荐文章于 2024-08-03 15:18:43 发布