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