嗨,我有这个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中,我如何将总和函数内的值求和,并返回它,谢谢
发布于 2019-02-23 18:57:52
根据需要的数据类型和精度,使用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);
},https://stackoverflow.com/questions/54844904
复制相似问题