zoukankan      html  css  js  c++  java
  • vue中的路由独享守卫的理解

    1.vue中路由独享守卫意思就是对这个路由有一个单独的守卫,因为他的守卫方式于其他的凡是不太同

    独享守卫于前置守卫使用方法大致是一样的

    1. 在路由配置的时候进行配置,
    {
            path:'/login',
            component:Login,
            beforeEnter(to,from,next){
                to.query.returnURL = from.path;
                next();
            }
        }

    2.在登陆界面就是需要返回的页面进行操作

    login(){
                axios.post('/user/login',this.user).then((res)=>{
                    localStorage.setItem('token',"Bearer "+res.data.res.token)
                     const url = this.$route.query.returnURL
                    // // console.log(this.$route)
                    this.$router.replace(url)
                })
            }

    rangthis.$router.replace(url),返回到点击进来 的页面,这样就可以实现返回的操作,当时returnURL不会在地址栏上进行显示

    希望自己写的东西能够对大家有所帮助!谢谢
  • 相关阅读:
    bzoj4196: [Noi2015]软件包管理器
    bzoj3083: 遥远的国度
    bzoj4034: [HAOI2015]T2
    2.EXIT_KEY
    AD如何1比1打印
    编程时注意,
    同步事件、异步事件、轮询
    事件位
    挂起进程相关API
    PROCESS_EVENT_POLL事件
  • 原文地址:https://www.cnblogs.com/mrxinxin/p/10190764.html
Copyright © 2011-2022 走看看