Vue Resolve error reporting Computed property '****' was assigned to but it has no setter.

  • 2021-10-15 09:37:06
  • OfStack

The following warning message was encountered in recent projects:

[Vue warn]: Computed property "currentStep" was assigned to but it has no setter

To solve this problem, we must first clarify the causes of this problem. This warning is due to the fact that there is no set method inside the Vue computed property, i.e. the computed property does not support value modification (only for values in data).


data(){
    return {
        stepMap:0
    }
},
computed:{
    currentStep:{
        get(){
             return this.stepMap
        },
        set(v){
            this.stepMap = v
        }
        // set Method only writes the following 1 Yes, it is ok 
        // set(){}
    }
}   

As shown above, this warning is resolved by manually adding different actions of the get and set methods to the calculated property.

The above is the details of Vue-Error Resolution Computed property "****" was assigned to but it has no setter. Please pay attention to other related articles on this site for more information on Error Resolution vue!


Related articles: