<el-form-item label="和值:" prop="a">
<el-input v-model="formData.a" placeholder="请填写"></el-input>
</el-form-item>
<el-form-item label="值1:" prop="b">
<el-input v-model="formData.b" placeholder=""></el-input>
</el-form-item>
<el-form-item label="值2:" prop="c">
<el-input v-model="formData.c" placeholder=""></el-input>
</el-form-item>
在watch中加:
'formData.b'(val) {
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);
}
},
运行时输入和值6,b的值0.4后,b的值变为0.4000000000000000,如下图,怎么解决啊啊啊?