初試 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