[VUE] Form validation - the object has been assigned and the input box prompt is empty

After assigning a value to the attribute value bound to the input box in the method, the submission still prompts that it cannot be empty. In fact, the data has been updated in the object, but the page is not rendered.

use

this.$forceUpdate();

 Forced update was found to be ineffective, so considering the diff algorithm, by defining the key, when the value changes, Vue can judge the data change and then update the page data.

Implementation:

						<el-form-item
							:label="输入框label名"
							prop="propVlue"
							:key="timer"  //添加key值
						>
							<el-input
								v-model="form.xxx"
								clearable
								class="form-item-box"
								:disabled="true"
							>
							</el-input>
						</el-form-item>

In the method that modifies the value add:

this.timer = new Date().getTime();

Guess you like

Origin blog.csdn.net/liusuihong919520/article/details/127917983