Vue路由判断前进后退

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/weixin_40825228/article/details/102490947
//注册全局方法
 
Vue.prototype.push = (url: string, closeTransition: boolean = false) => {
    //前进
    Vue.prototype.transitionName = "slide-left";
    this.$router.push(url);
};
 
Vue.prototype.pop = (n: number = -1, closeTransition: boolean = false) => {
    //后退
    Vue.prototype.transitionName = "slide-right";
 
    let path = this.$router.currentRoute.path;
    if (path == "/") {
        return;
    }
    this.$router.go(n);
};

猜你喜欢

转载自blog.csdn.net/weixin_40825228/article/details/102490947