Vue.js搭建路由报错 router.map is not a function怎么办
发布时间:2018-03-16 来源:查字典编辑
摘要:错误:出现问题原因:2.0已经没有map这个方法了,只有1.0兼容该方法。解决方法:(1)方法1:使用命令npminstallvue-rou...
错误:

出现问题原因:2.0已经没有map这个方法了,只有1.0兼容该方法。
解决方法:
(1)方法1:使用命令npm install vue-router@0.7.13兼容1.0版本vue。

在代码中的使用方法:

(2)解决方法2:基于vue2.0,写对应的方法。
具体用法如下图:

注:1.0和2.0在一些用法上有比较大的差别,用的时候需要注意。