今天调试的时候浏览器报错——TypeError: Object(...) is not a function,通过检查代码发现没有问题,通过排查是vue-router的版本引用错误。
原因:因为自己使用的vue2.x,vue2.x不能使用4.x版本vue-router,因此导致上面的错误。4.x版本的vue-router只能在3.x版本的vue中使用。
解决办法:vue2.x不能使用4.x版本vue-router,因此卸载vue-router,然后安装3.x版本的vue-router。
操作如下:
1、卸载vue-router
npm uninstall vue-router
2、安装3.x版本的vue-router
npm install --save vue-router@3