python语言求商品的总价_计算商品总价?

如何通过checkbox计算选中商品得价格?

  • {{item.book_title}}

    ¥{{item.book_price}}

{{mount}}

合计

¥{{total}}

提交订单

import BreadCrumb from '@/components/common/BreadCrumb'

export default {

components: {

BreadCrumb

},

data () {

return {

breadCrumbList: [],

bookList: [],

radio: '0',

checkList: [],

num: 1,

mount: 0,

total: 0

}

},

mounted () {

this.breadCrumbList = [

{title: '首页'},

{title: '图书管理'},

{title: '图书借阅'}

],

this.bookList = [{

id: '0',

book_url: require('../assets/images/book1.jpg'),

book_title: '古埃及死者之书',

book_price: '39',

num: 0

},{

id: '1',

book_url: require('../assets/images/book2.jpg'),

book_title: '当你开始爱自己',

book_price: '45',

num: 0

},{

id: '2',

book_url: require('../assets/images/book3.jpg'),

book_title: '格雷巴旅馆',

book_price: '59',

num: 0

},{

id: '3',

book_url: require('../assets/images/book4.jpg'),

book_title: '亲密关系',

book_price: '30',

num: 0

},{

id: '4',

book_url: require('../assets/images/book5.jpg'),

book_title: '治愈的力量',

book_price: '25',

num: '0'

},{

id: '5',

book_url: require('../assets/images/book6.jpg'),

book_title: '公主走进黑森林',

book_price: '69',

num: 0

}

]

},

methods: {

onOrder () {

},

handleCheckedBooks () {

console.log(this.checkList)

},

handleChange (val) {

this.mount++

this.calcTotalMoney()

},

calcTotalMoney () {

let totalMoney = 0

this.checkList.forEach((item) => {

totalMoney += item.num *item.book_price

})

this.total = totalMoney

}

}

}

现在checkList只能获取到选中项得id是怎么回事?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值