Computed property "dialogFormVisible" was assigned to but it has no setter

最近在使用vue开发项目的时候  使用vuex。需要在不同页面监听vuex中的某个值的变化。

发现在界面中 如果某个DOM需要根据某个属性值来控制显隐  比如  v-if="temp" 或者 双向绑定的时候 v-model="temp" (temp的值根据vux中的某个值进行改变)

此时会报错  Computed property "dialogFormVisible" was assigned to but it has no setter

查找文档后发现 使用v-model  v-if 的时候需要设置setter

则原代码

dialogFormVisible: function() {
      return this.$store.state.bigScreen.dialogFormVisible
    }

需要做如下改变

dialogFormVisible: {
      get: function() {
        return this.$store.state.bigScreen.dialogFormVisible
      },
      set: function() { //因为我这里并不需要其他属性也跟着一起改变 所以就这样写了
        console.log('1')
      }
    }

 

你可能感兴趣的:(vue)