computed里面定义的内容area,但是报错"area" was assigned to but it has no setter

这种问题一般是area这个计算属性没有设置set方法导致该报错,

因为在methods方法里面有对area赋值的操作。只要添加一个 set方法就可以解决此报错。

computed:{
    area:{
         get: function () {
            return this.myAddressProvince+this.myAddressCity+this.myAddresscounty;//methods里面对这个里面有从新赋值的操作
        },
      set: function (newValue) {
         //  console.log(newValue)。//这个newValue能监听到methods里面从新赋值了,这个就是新值.
      }
        
    },
}

猜你喜欢

转载自blog.csdn.net/qq_33769914/article/details/85261729