《vue》1.eslint语法限制项目报错解决办法

《vue》1.eslint语法限制项目报错解决办法

闲暇时候开始写毕设,使用webstorm新建了vue项目,发现每次npm run dev打开都会报一长错,但是不影响项目运行。

报错信息如下:

13% building modules 25/36 modules 11 active ...\Users\apple\Desktop\ncp1\src\App.vue{ parser: "babylon" } is deprecated; we now treat it as { parser: "b 95% emitting
WARNING  Compiled with 1 warnings                                                                          10:49:38 AM
  ✘  http://eslint.org/docs/rules/spaced-comment  Expected space or tab after '//' in comment
  src\router\index.js:4:1
  //首页
  ✘  http://eslint.org/docs/rules/comma-dangle    Unexpected trailing comma
  src\router\index.js:18:6},
✘ 5 problems (5 errors, 0 warnings)
Errors:
  2  http://eslint.org/docs/rules/comma-dangle

  2  http://eslint.org/docs/rules/key-spacing

  1  http://eslint.org/docs/rules/spaced-comment

You may use special comments to disable some warnings.

Use // eslint-disable-next-line to ignore the next line.

Use /* eslint-disable */ to ignore all warnings in a file. 

在这里插入图片描述
报错信息翻译:

Missing space before value for key ‘meta’=====>值前缺少空格

Unexpected trailing comma================>意外的尾随逗号

You may use special comments to disable some warnings.===>您可以使用特殊注释来禁用某些警告。

Use // eslint-disable-next-line to ignore the next line.===>使用//eslint disable next line忽略下一行。

Use /* eslint-disable */ to ignore all warnings in a file. ===>使用/eslint disable/忽略文件中的所有警告。

大致意思呢就是说,eslint是一个语法检查工具,但是限制很严格,vue文件里面很多空格等书写格式规范都会导致报错出现红线(红线点击红色灯泡式提示即可关闭)。

报错不影响代码运行。可以关闭,但是在编译的时候老是会跳出来红彤彤的一片看起来也是够头疼的。

解决方法如下:

在build/webpack.base.conf.js文件中,注释或者删除掉:module->rules中有关eslint的规则:

  module: {
    rules: [
      // ...(config.dev.useEslint ? [createLintingRule()] : []),===》此段注释或删除
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: vueLoaderConfig
      },

在这里插入图片描述
当然这些报错部分都改了也可以,而且能够提高代码的可读性,也显得更加整齐一点。

(技术问题欢迎留言讨论,前进路上你我同行,所有文章均为亲测有效后再还原记录在册哒)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值