初试 vue2.0——7.项目开发_路由重定向


写在前面的话:

  在vue1.0中的方式(貌似使用的是 go),在2.0中不太一样了。

做法:在index.js中,加入 redirect配置即可。

 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 })
View Code

实例截图:

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM