购物车选中商品价格的累加 vue

    getTotalPrice(){
      let balance = this.car.filter( (item,index) => this.checkboxarray[index]) ;
      return balance.reduce((sum,item) => sum + item.onlinePrice*item.num,0)
    }

1.通过filter方法来筛选出选中的数据

2.把选中的数据通过reduce方法进行累加处理

原文地址:https://www.cnblogs.com/pwindy/p/13274142.html