Change the state in the vue page and render the view (set the disabled attribute of the input)

Directly changing the status page in data cannot be rendered immediately. Trying to use forced rendering and this.$nextTick(()=>{}) method still has no effect

Vue cannot detect the addition or removal of object properties. Since Vue performs a getter/setter conversion process on property traversal when initializing an instance, the property must exist on the data object for Vue to convert it so that it is responsive.

Need to call this.$set() method

his.$set()是将set函数绑定在Vue原型上
this.$set(Object, key, value)
// 有时你想向已有对象上添加一些属性,例如使用 Object.assign() 或 _.extend() 方法来添加属性。
// 但是,添加到对象上的新属性不会触发更新。
// 在这种情况下可以创建一个新的对象,让它包含原对象的属性和新的属性:

this.someObject = Object.assign({
    
    }, this.someObject, {
    
     a: 1, b: 2 })



if (val === "0") {
    
    
     this.$set(this.FormConfig.data[0], "disabled", true);
       } else {
    
    
     this.$set(this.FormConfig.data[0], "disabled", false);
                }
},

Guess you like

Origin blog.csdn.net/Xiang_Gong_Ya_/article/details/131658596