Vue 打包后报错 Uncaught TypeError: Cannot redefine property: $router


原因:就如报错提示所描述的,不能重新定义$router,说明是重复定了$router。通常是因为在项目中安装了vue-router的依赖并且用Vue.use()使用了vue-router,还在index.html页面引入了vue-router.js文件。

解决方法有两种:

  1. 去掉index.html中的vue-router.js文件的引入。如果没有使用externals的话可以直接使用这种方法。

  2. 删除vue-router的依赖,包括依赖包和package.json中的vue-router。使用了externals来外部引入vue-router的话则用这种方法。

提示:从vue-router.js文件引入的router对象名为VueRouter,新建router对象是 new VueRouter()。

https://www.cnblogs.com/mengyouyouyou/p/10936171.html


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



猜您在找 vue报错 Uncaught TypeError: Cannot read property ‘children ’ of null Vue的报错:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#' vue报错getVueAllUser:67 Uncaught TypeError: Cannot read property 'userId' of undefined 前台报错:Uncaught TypeError: Cannot read property '0' of null js 报错 Uncaught TypeError: Cannot read property 'trim' of undefined VUE——Uncaught (in promise) TypeError: Cannot read property '__esModule' of undefined vue-cli4创建项目导入elementUI,浏览器报错Uncaught TypeError: Cannot read property ‘prototype‘ of undefined Uncaught TypeError: Cannot read property 'trim' of undefined Uncaught TypeError: Cannot read property 'filter' of null Uncaught TypeError: Cannot read property 'nodeType' of undefined
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM