定义了:goodsList:[
{
id: 1,
name: 'BANDALY 2020夏季女装连衣裙韩版大码宽松显瘦套装裙子两件套 JX19301 上豆绿下米白 M ',
price: 21900,
vip_price: 12900,
img: '/static/img/goods_thumb_01.png',
is_goods: 0,
},{
id: 1,
name: '花花公子 卫衣男秋季圆领薄款休闲体恤男士时尚长袖T恤外套上衣男生情侣装套头衣服秋天男装 白色 XL',
price: 13900,
vip_price: 9900,
img: '/static/img/goods_thumb_02.png',
is_goods: 1,
},
需要求价格总和计数,用computed:
computed: {
name() {
return this.data
},
totalA(){
let arr = 0
let arr1 = this.goodsList.price
return this.arr1.reduce((arr,arr1)=>arr+arr1,0)
报错:
Error in render: "TypeError: Cannot read properties of undefined (reading 'reduce')"
求大神帮助
1 个回复
uniapp程序开发 - uniapp&php程序开发,有开发需求,+我:angelcry00
你 let 定义的arr1 ,怎么用this.arr1