起初我是这样写的
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('/','');
}
}
},