Computed property “XXX” was assigned to but it has no setter

 起初我是這樣寫的

  computed:{
            onRoutes(){
                return this.$route.path.replace('/','');
            }
        },

 然後就報錯了

clipboard.png

這樣的話是因爲計算屬性沒有寫set和get,寫上就好了

                    
                    
 computed:{
            onRoutes:{
                set:function () {
                    return this.$route.path.replace('/','');
                },
                get:function(){
                    return this.$route.path.replace('/','');
                }
               
            }
        },

 

如果遇到此類問題的話可以加我微信我幫你解決  加微信記得發個紅包哦!!!!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章