vue常见报错汇总
1.Uncaught SyntaxError: Unexpected identifier
找到相应的行数,看看是不是少了个逗号…再或者是不是字符串没有加双引号?。
2.Uncaught SyntaxError: Invalid or unexpected token
翻译:”无效或意外的标记“。
找到相应行数,是不是中英文符号切换错了…十之八九。
3.[Vue warn]: Property or method “success” is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
你使用的属性或者方法没有定义…看看你的methods或者prop/data吧…
4.Module not found: Error: Can’t resolve 'types.js’
找不到模块,因为这这是引入type.js文件,本身就不是模块,错误原因是没有加相对路径 ‘ ./ ’
5.Module build failed: Error: No parser and no file path given, couldn’t infer a parser.
没有语法分析器和文件路径,无法推断解析器
原因: 依赖包出现问题,prettier 一个vue-cli的依赖,把一个feature 的移除当作次版本发布
解决: npm install --save-dev prettier@1.12.0(删除 node_modules下_prettier@1.13.0@prettier文件夹)
6.Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.
组件模板应该只包含一个根元素