如何通过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是怎么回事?