vue——this.$route 与 this.$router

this.$route 包含的是路由基本信息,如fullPath等,

this.$router 在原型链(__proto__)中包含路由的处理方法,如跳转push等。

this.$router.push('/')   //跳转到根目录,保留历史记录,可以返回
this.$router.replace('/')  //跳转到根目录,替换掉当前历史记录,无法返回替换前的页面
this.$router.back()  //返回上一个页面
this.$router.go(1) // 1 为向前跳转,-1 为返回(相当于back)

猜你喜欢

转载自blog.csdn.net/YUHUI01/article/details/83722359
今日推荐