起初我是這樣寫的
computed:{
onRoutes(){
return this.$route.path.replace('/','');
}
},
然後就報錯了
這樣的話是因爲計算屬性沒有寫set和get,寫上就好了
computed:{
onRoutes:{
set:function () {
return this.$route.path.replace('/','');
},
get:function(){
return this.$route.path.replace('/','');
}
}
},