我有以下代码并收到 TS2345 错误。我用过 Angular 7。
let totalAmount = quantity*rate;
let discountAmount = totalAmount - (totalAmount*discount)/100;
let finalValue = parseFloat(discountAmount - (discountAmount - (discountAmount * (100/(100+tax))))).toFixed(2).toString();
taxableAmount.setValue(finalValue);
最佳答案
你能去掉parseFloat
吗? parseFloat
需要一个字符串作为参数,但你传递的是一个 number
,
let totalAmount = quantity * rate;
let discountAmount = totalAmount - (totalAmount * discount) / 100;
let finalValue = (
discountAmount -
(discountAmount - discountAmount * (100 / (100 + tax)))
)
.toFixed(2)
.toString();
关于angular - 我收到错误 TS2345 : Argument of type 'number' is not assignable to parameter of type 'string' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57837937/