The problem behind the decimal point of the data number in Vue, unable to display a number similar to 1.00?

recently, using vue, to display data requires saving unified two decimal places, such as 1.11, but if you save 1.00, the Console.log will directly be 1 instead of 1.00. How to solve this problem

data () {

return {
    number1: 1.00,
    number2: 1.12
}

}

because to sort these of numeric types, calculate averages and so on, you need numeric types

Apr.08,2021

you can use Number.toFixed (2)
var a = 1;
a.toFixed (2) / / a = 1.00


  computed: {
    strNumber1: function () {
      // `this`  vm 
      return this.number1.toFixed(2)
    }
  }

ide/computed.html-sharp%E8%AE%A1%E7%AE%97%E5%B1%9E%E6%80%A7" rel=" nofollow noreferrer "> calculation properties

Menu