问题:
给上图中两个el-input赋值如下
element-ui代码:
<el-form-item label="宽度:" prop="w" :label-width="formLabelWidth">
<el-input v-model.number="formdata.w" placeholder="宽度 单位:毫米(mm)"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="高度:" prop="h" :label-width="formLabelWidth">
<el-input v-model.number="formdata.h" placeholder="高度 单位:毫米(mm)"></el-input>
</el-form-item>
</el-col>
_self.formdata.w = parseInt(wh[0]);
_self.formdata.h = parseInt(wh[1]);
结果在页面上不能编辑el-input的值。网上一顿搜索,得知用Vue的全局api $set(),把属性处理成一个响应式的属性,此时视图也会跟着改变了
_self.$set(_self.formdata,'w',parseInt(wh[0]))
_self.$set(_self.formdata,'h',parseInt(wh[1]))