购物车结算
手机:价格: 数量:
type="text"
v-model.number="count1"
/>
小计:{{ price1 * count1 }}
电脑:价格: 数量:
type="text"
v-model.number="count2"
/>
小计:{{ price2 * count2 }}
共计:{{ price1 * count1 + count2 * price2 + pay }}
优惠:{{ price1 * count1 + count2 * price2>8000?discount=200:discount=100 }}
应付:{{
price1 * count1 + price2 * count2 + pay - discount
}}
export default {
name: "Shopcar",
data() {
return {
// 手机价格
price1: 0,
// 手机数量
count1: 0,
// 电脑价格
price2: 0,
// 电脑数量
count2: 0,
// 运费
pay: 0,
// 优惠
discount:0
// 总计
// sum:'price1 * count1+price2 * count2'
};
},
computed: {
// discount() {
// if (5000 // return 100 // } // else if(this.price1 * this.count1 + this.count2 * this.price2 >= 8000) { // return 200 // } // else { // return 0 // } // } // discount: { // // set() { // // if ( // // 5000 < // // this.price1 * this.count1 + this.count2 * this.price2 < // // 8000 // // ) { // // this.discount = 100; // // } // // }, // // get() { // // if(5000 // // return 100 // // } // // else { // // return 200 // // } // // }, // }, }, }; li { list-style: none; }



