Vue——解决报错 Computed property "****" was assigned to but it has no setter.

  We encounter the following warning message in a recent project:

  [Vue The warn]: Computed Property "currentStep " But IT WAS Assigned to has NO setter. (Meaning: Calculate property currentStep is assigned, but it does not define this set methods)

  To solve this problem, we must first clear the cause of this problem. This warning is due to the internal calculation of property Vue no set method, namely: do not support the calculation of property worth modification (can only be calculated for the value of data in).

  

Data () { 
    return { 
        stepMap: 0 
    } 
}, 
computed: { 
    currentStep: { 
        GET () { 
             return this.stepMap 
        }, 
        SET (V) { 
            this.stepMap = V 
        } 
        // SET method is only possible to write the following line the 
        // SET () {} 
    } 
}    

 

  As indicated above, as long as the manual calculation attribute get and set methods of adding the different operations, this warning is solved.

 

Guess you like

Origin www.cnblogs.com/belongs-to-qinghua/p/11936476.html