vue-代码跳转路由

  之前路由的跳转都是通过router-link标签来做到,但有时候也是需要通过JS代码来进行路由的跳转,也是可以实现的,如下:

    this.$router.push('/home') //跳转路由,可前进后退
    this.$router.replace('/about') //跳转路由,不可前进后退

  $router是vue-router插件提供的一个全局变量,可用于全部的组件来使用。

原文地址:https://www.cnblogs.com/ibcdwx/p/14605241.html