1. 我们主要在index.js重新设置路由的重新定向redirect参数
index.js
import Vue from 'vue' import Router from 'vue-router' import HelloWorld from '@/components/HelloWorld' import Params from '@/components/Params' Vue.use(Router) export default new Router({ routes: [ { path: '/', name: 'HelloWorld', component:HelloWorld },{ path:'/params/:Id/:Title', component:Params },{ path:'/goHome', redirect:'/' }, { path:'/goparams/:Id/:Title', redirect:'/params/:Id/:Title' //这里对应的是重定向的path path:'/params/:Id/:Title',
} ] })
2.在App.vue 设置vue-router
<router-link to="/">首页</router-link>
<router-link to="/params/2018-6-18/世界杯">params</router-link> |
<router-link to="/goHome">go 首页</router-link>
<router-link to="/goparams/2018-6-19/我们">GOparams</router-link>
效果: