vue 计算总金额
vue计算总金额var app = new Vue({el:'#app',form: {total_num:10,money:1;totalMoney:0,},computed: {sum: function() {if(this.form.total_num < 0) {return parseFloat(0).toFixed(2...
·
vue计算总金额
var app = new Vue({
el:'#app',
form: {
total_num:10,
money:1;
totalMoney:0,
},
computed: {
sum: function() {
if(this.form.total_num < 0) {
return parseFloat(0).toFixed(2);
}
return parseFloat(this.form.total_num * this.form.money).toFixed(2);
}
},
watch: {
sum: {
handler(val) {
this.form.totalMoney = val
},
immediate:true,
deep:true
}
}
})
更多推荐
已为社区贡献1条内容
所有评论(0)