vue-常见错误解决 1.运行vue时浏览器报错Unknown custom element: custom-select - did you register the component correctly? For recursive components, make sure to provide the name option原因被引用的组件页面没有进行export导致寻找不到浏览器console报错但是编译的时候没有语法问题不报错解决方法1 export { default as AppMain } from ./AppMain方法2将vue/dist/vue.esm.js注销修改为vue/dist/vue.min.js2.vue router 报错Uncaught (in promise) NavigationDuplicated {_name:NavigationDuplicated... 的解决方法参考网站https://blog.csdn.net/weixin_43202608/article/details/98884620在点击 router-link 会造成报错的问题 报错内容为1解决方法很简单把项目依赖的 node_modules 文件夹删除 然后再 npm install 重新下载依赖包就可以解决2发现以上方法很多人都不能成功解决经过多次尝试发现原因可能是 在重新下载依赖包时安装的vue-router还是之前出错的那个版本那么要怎么解决呢解决方法也很简单在项目目录下运行 npm i vue-router3.0 -S 即可3在main.js下添加一下代码import Router from vue-routerconst originalPush Router.prototype.pushRouter.prototype.push function push(location) {return originalPush.call(this, location).catch(err err)}3.Vue报错 [Vue warn]: Property or method name is not defined on the instance but referenced.....原因:在data中没有定义一个name, 致错解决方法:在data中定义一个name ,[Vue warn]: Property or method value is not defined on the instance but referenced.....原因:template中定义了属性如v-model但在data中没有定义一个value解决方法:在data中定义一个value ,以下转载高手文章https://blog.csdn.net/zn740395858/article/details/804861794.Error in render: TypeError: Cannot read property ‘list’ of undefined**报错**渲染错误“未定义的Type Error无法读取属性”列表**原因**没给list定义也就是说在temple中用到list了但是在data中没定义这个字段如果已经定义了但是还是报错请检查下自己是否拼错了单词因为我就是这么蠢了 解决data () { return { list: [] } },5.[Vue warn]: Property or method “message” is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property报错message没定义原因跟上面的一样message在data那里没有定义定义一个初始值就好解决data() { return { message: } },6.Module build failed: Error: No parser and no file path given, couldn’t infer a parser.报错没有语法分析器和文件路径无法推断解析器原因依赖包出现问题prettier 一个vue-cli的依赖把一个feature 的移除当作次版本发布解决npm install --save-dev prettier1.12.0删除 node_modules下_prettier1.13.0prettier文件夹7.routes forEach is not a function原因forEach routes没有发现里面有值解决1.查看import {routes} from ./routes’这个路径是否正确2.routes是一个数组检查routes是否是一个数组3.是否已经new了一个router又再次new一遍?// main.js // 路由配置 const RouterConfig { // 使用HTML5的History模式 mode: history, routes: Routers } // new VueRouter const router new VueRouter(RouterConfig) // router.js // 在router中又再次new一遍重复了 export default new Router({ routes: [ { path: /, name: home, component: home } ] }) 改为 // router.js const routers [ { path: /home, meta: { title: 主页 }, component: (resolve) require([../page/home.vue], resolve) ] export default routers8.[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the “name” option.原因被引用的组件页面没有进行export导致寻找不到浏览器console报错但是编译的时候没有语法问题不报错解决export { default as AppMain } from ./AppMain9.TypeError: Cannot read property ‘vue’ of undefined报错信息ERROR in ./src/login.vue Module build failed (from ./node_modules/_vue-loader13.7.3vue-loader/index.js): TypeError: Cannot read property ‘vue’ of undefined at Object.module.exports (F:\VistualStudioCode\threess\node_modules_vue-loader13.7.3vue-loader\lib\load er.js:61:18) ./src/main.js 7:13-35 multi ./node_modules/_webpack-dev-server3.1.10webpack-dev-server/client?http://localhost:3000 (webpack)/h ot/dev-server.js ./src/main.js原因vue-loader这个插件被破坏了解决// 重新安装依赖 npm install vue-loaderlatest --save-dev