vue项目小问题总结

 在初始化项目时有个选项Use ESLint to lint your code? (Y/n)

如果选择是yes,则有可能在你写.vue文件的js时会报以下错误:

✘  http://eslint.org/docs/rules/indent  Expected indentation of 0 spaces but found 2
  src\pages\Main.vue:87:1
    export default {
   ^

  ✘  http://eslint.org/docs/rules/indent  Expected indentation of 2 spaces but found 4
  src\pages\Main.vue:88:1
      name: 'Main',
   ^

  ✘  http://eslint.org/docs/rules/indent  Expected indentation of 2 spaces but found 4
  src\pages\Main.vue:89:1
      data () {
   ^

  ✘  http://eslint.org/docs/rules/indent  Expected indentation of 4 spaces but found 6
  src\pages\Main.vue:90:1
        return {
   ^

  ✘  http://eslint.org/docs/rules/indent  Expected indentation of 6 spaces but found 8
  src\pages\Main.vue:91:1
          msg: 'Welcome to Your Vue.js App'
   ^

  ✘  http://eslint.org/docs/rules/indent  Expected indentation of 4 spaces but found 6
  src\pages\Main.vue:92:1
        }
   ^

  ✘  http://eslint.org/docs/rules/indent  Expected indentation of 2 spaces but found 4
  src\pages\Main.vue:93:1
      }
   ^

  ✘  http://eslint.org/docs/rules/indent  Expected indentation of 0 spaces but found 2
  src\pages\Main.vue:94:1
    }
   ^


✘ 8 problems (8 errors, 0 warnings)


Errors:
  8  http://eslint.org/docs/rules/indent

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.复制代码

这个错误因为你设置了eslint,但你的js代码不规范的原因,其实错误已经很清晰,大多数就是缩进不规范,分号不需要等原因,很容易解决的,如果你不想有规范的js代码,可以重新初始化关掉eslint。

在bulid/webpack.base.conf.js里面有配置如下:
module: {
rules: [

...(config.dev.useEslint ? [createLintingRule()] : []),复制代码

点进config.dev.useEslint,发现在config/index.js里配置
useEslint: true, // 改为false即可。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值