Vue.js搭建路由報錯 router.map is not a function,Cannot read property ‘component’ of undefined


綜述:一開始我遇到的問題是,router.map is not a function,然后我在網上查,就安裝了npm install vue-router@0.7.13兼容1.0版本,就沒有報這個錯了,但是又報了一個新錯Cannot read property ‘component’ of undefined,然后看了你的這篇,就安裝了npm install vue-router@next,就沒有報Cannot read property ‘component’ of undefined的錯了

 

錯誤:

解決辦法:

2.0已經沒有map了,使用npm install vue-router@0.7.13 命令兼容1.0版本vue

再引入文件

 ****************************************************
上面解決之后可能又會出現
問題  Cannot read property ‘component’ of undefined

原因

版本問題,由於vue2刪除了vue1的內部指令,而vue-router1.x依賴vue的一個內部指令。

這上面如果是1.x版本,會讀取Vue.internalDirectives.component這個屬性,而實際上vue2根本沒有Vue.internalDirectives,所以導致undefined。

解決方法

vue-router-next 
到這里下載即可,或者

npm install vue-router@next


原文鏈接:http://blog.csdn.net/sunOpar/article/details/52471582
原文鏈接:http://blog.csdn.net/gaoxiaoba/article/details/52813867
 


免責聲明!

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



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