Vue项目启动报错

293 阅读1分钟

前情提要:在开发vue项目的过程中,使用了eslint进行语法校验,过程中会产生一些报错。写本篇文章的目的是对实践过程中的报错进行记录,方便日后查阅。 eslint.org/docs/rules/…

1.✘ Expected indentation of 0 spaces but found 2

起因:使用 webstorm vue模板生产的 .vue 文件,script标签默认会有缩进

解决方案:

①在工程根目录下找到.eslintrc.js

②在rules标签中添加 'indent': 'off'

rules: {
  'indent': ['off', 2]
}

2.✘ google.com/#q=vue%2Fva… The template root requires exactly one element

起因:template 标签中不能为空,必须有且只有一个根元素

解决:template 标签中添加一个根元素