value.toFixed is not a function
时间: 2023-09-24 09:11:44 浏览: 73
微信小程序 保留小数(toFixed)详细介绍
This occurs when you try to use the `toFixed()` method on a non-numeric value. The `toFixed()` method is used to convert a number into a string, with a specified number of digits after the decimal point.
To fix this error, make sure that the value you are trying to use `toFixed()` on is a number. You can use the `typeof` operator to check if the value is a number before using the `toFixed()` method. For example:
```
let value = "123.456";
if (typeof value === "number") {
let fixedValue = value.toFixed(2);
console.log(fixedValue);
} else {
console.log("Value is not a number");
}
```
阅读全文