vue 路由监控

1,590 阅读1分钟

除了常用的路由拦截之外,在单独页面对路由监控:

watch:{
        $route(to,from){
            switch(to.path){
                case '/':
                    this.activeName = '1-1'
                    break;
                case '/syncRecord':
                    this.activeName = '1-2'
                    break; 
                default:
                    this.$router.push('/')
                    this.activeName = '1-1'
                    break;        
            }
        }
    },