// 监听路由,每次进入页面调用方法,放在method里
mounted(){
this.getPath()
},
methods: {
getPath(){
console.log(this.$route.path);
if (this.$route.path == '你要进入的路由') {
this.init() // 初始化的方法
}
}
},
watch: {
'$route':'getPath'
},