Computed property was assigned to but it has no setter.

There is a very strange bug today. We can see the reason for the error very clearly. The calculated attribute has no setter.
Insert picture description here
This is the source code of the calculated attribute. The calculated attribute has getter and setter. The default is only getter. You can set the setter if needed

 computed:{
    
    
    isActive(){
    
    
      return this.$route.path.indexOf(this.path) !== -1
    }
  },

Although the effect is still achievable, it will report an error every time I use the data. I read the official vue documentation and the
Insert picture description here
official demo does not have a setter. Why should I report an error if I don't set the setter?
The final modification plan:

computed:{
    
    
    isActive:{
    
    
      get(){
    
    
      return this.$route.path.indexOf(this.path) !== -1
      },
      set(val){
    
    }
    }
  },

Guess you like

Origin blog.csdn.net/d1063270962/article/details/113761889