写在前面的话:
在vue1.0中的方式(貌似使用的是 go),在2.0中不太一样了。
做法:在index.js中,加入 redirect配置即可。
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 import Vue from 'vue' 2 import Router from 'vue-router' 3 import goods from 'router/goods/goods' 4 import ratings from 'router/ratings/ratings' 5 import seller from 'router/seller/seller' 6 7 Vue.use(Router) 8 9 export default new Router({ 10 routes: [ 11 { 12 path: '/', 13 redirect: '/goods', 14 component: goods 15 }, 16 { 17 path: '/goods', 18 name: 'goods', 19 component: goods 20 }, 21 { 22 path: '/ratings', 23 name: 'ratings', 24 component: ratings 25 }, 26 { 27 path: '/seller', 28 name: 'seller', 29 component: seller 30 } 31 ] 32 })
实例截图: