嗨,我有这个vuejs2代码
totals() {
this.total = 0;
console.log(this.total_without_discount);
console.log(this.total_taxs);
console.log(this.total_discount);
this.total += this.total_without_discount;
this.total += this.total_taxs;
this.total += this.total_discount;
return Number(this.total).toFixed(this.comma);
},
现在,当我得到结果后,我就回到南
所有这些功能都在computed
中
我如何将合计函数中的值求和并将其返回
谢谢
答案 0 :(得分:1)
根据所需的数据类型和精度,使用parseInt或parseFloat:
totals() {
this.total = 0;
this.total += parseFloat(this.total_without_discount);
this.total += parseFloat(this.total_taxs);
this.total += parseFloat(this.total_discount);
return parseFloat(this.total).toFixed(this.comma);
},