在使用el-checkedbox,el-input等组件时候,使用了v-model绑定了参数,通过另外的组件或者函数改变参数的值时,经常会有控制台已经可以打印出值了,但是在视图上没有显示出来,或者是在有其他操作后,该改变才会后一步显示出来。这时候就需要用this.$set()来更改参数的值,这样就可以在视图上响应。
-
调用方法:this.$set( target, key, value )
-
target:要更改的数据源(可以是对象或者数组)
-
key:要更改的具体数据
-
value :重新赋的值
this.$set(this.form, 'UserID', res.data.UserID)
this.$set(this.form, 'LoginID', res.data.LoginID)
this.$set(this.form, 'UserName', res.data.UserName)
this.$set(this.form, 'ShortName', res.data.ShortName)
this.$set(this.form, 'PostName', res.data.PostName)