当前位置:   article > 正文

Vue中this.$router.push()失效解决办法_this.$router.push无法跳转

this.$router.push无法跳转

问题描述

今天学习Vue的时候准备使用this.$router.push()来跳转页面,但是无论如何也跳转不了,也没有报错.
路由如下:

{
        path:'/home',
        component:home,
        name:home
    },

    {
        path: '/login',
        component:login,
        name:login
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

从login界面跳转到home界面不成功

解决办法

引入router,将this.$router.push()改为router.push()方法进行页面跳转

import router from "@/router";
router.push({path:'/home'})
  • 1
  • 2
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/285259
推荐阅读
相关标签
  

闽ICP备14008679号