Vue-router 2.0 沒有效果顯示的原因


前段時間 Vue升了2 相應vue-router,vue-cli 也升了2,最近我也在學,坑不少,加上wepack 和ESlint 的語法,差點奔潰,

廢話不說上代碼

 1 import Vue from 'vue'
 2 import App from './App'
 3 import VueRouter from 'vue-router'
 4 // 引入子組件到路由
 5 import goods from './components/goods/goods.vue'
 6 import seller from './components/seller/seller.vue'
 7 import ratings from './components/ratings/ratings.vue'
 8 
 9 Vue.config.productionTip = false
10 
11 Vue.use(VueRouter)
12 
13 let router = new VueRouter({
14   routes: [  //!!!! 注意這里 是 routes 不是 routers 沒有 'r' 15     {path: '/goods', component: goods},
16     {path: '/seller', component: seller},
17     {path: '/ratings', component: ratings}
18   ]
19 })
20 
21 /* eslint-disable no-new */
22 new Vue({
23   el: '#app',
24   template: '<App/>',
25   components: { App },
26   router: router
27 })

 構造函數 VueRouter 里面的是 routes ,而不是routers ,切記切記~~~


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM