After binding the data input input box in v-modle, watch monitors the input data and automatically calculates the difference

< el-form-item label= "and value:" prop= "a" >

<el-input v-model="formData.a" placeholder=""></el-input>

< / el-form-item >
< el-form-item label= "value 1:" prop= "b" >

<el-input v-model="formData.b" placeholder=""></el-input>

< / el-form-item >
< el-form-item label= "value 2:" prop= "c" >

<el-input v-model="formData.c"  placeholder=""></el-input>

< / el-form-item >

add:
"formData.b" (val) {

to watch
    if (this.formData.a && this.formData.b) {
      this.formData.c = parseFloat(this.formData.a) - parseFloat(this.formData.b);
    }
  },
  "formData.c"(val) {
    if (this.formData.a && this.formData.c) {
      this.formData.b = parseFloat(this.formData.a) - parseFloat(this.formData.c);
    }
  },

when you enter a value of 0.4 for the sum of 6 ~ # b at run time, the value of b changes to 0.4000000000000000. as shown in the figure below, how to solve it?

Mar.05,2021
Menu