搜索文档
知识点
- 非编程式路由是依靠
<router-link></router-link>标签实现的页面跳转。 - 编程式路是借助 vc.$router 完成页面的跳转。
$router API
push
以追加浏览器历史记录的形式跳转页面。
javascript
this.$router.push({
path: '/home',
query: {
title: 'Hello',
time: '2022-01-23'
}
});replace
以替换当前浏览器历史记录的形式跳转页面。
javascript
this.$router.replace({
path: '/home',
query: {
title: 'Hello',
time: '2022-01-23'
}
});back
跳转到上一页。历史记录中栈针下移。
javascript
this.$router.back();forward
跳转到下一页。历史记录中栈针上移。
javascript
this.$router.forward();go
跳转页面,参数为正数表示向后跳转 n 页,负数表示向前跳转 n 页。
javascript
this.$router.go(-1); // 跳转到上一页
this.$router.go(1); // 跳转到下一页