Vue路由重定向

欢迎一起讨论

Geooo的个人博客:https://geooo.gitee.io/geoooblog/

  • Vue路由对象:$router
  • 路由跳转方法: push( )
  • 实现:$router.push('url')

方法一:我们可以自己先建一个路由对象,调用 push() 方法进行跳转

myrouter.push(' 重定向的path ')




方法二:在方法体中加入钩子函数:

confirmPasswd (passwd) {
      if (passwd === '123456') {
        // this.showSuccessAlert('success', 'default')
        //密码正确
        this.$router.push({
          name: 'zdws-index'
        })

      } else {
        this.showErrorAlert('primary', 'default')
      }
    }

待添加...Continue...

原文地址:https://www.cnblogs.com/Geooo/p/11279490.html