用vue手脚架生成的项目直接修改时.vue文件后,保存编译就报一大堆的错,这是咋回事呢?

app.vue代码如下:

<template>
    <div id="app">
         <h1 v-text="title"></h1>
         <input v-model="newItem" @keyup.enter="addNew" />
         <ul>
             <li v-for="item in items" v-bind:class="{finished:item.isFinished}" v-on:click="toggleFinish(item)">
                 {{ item.label }}
             </li>
         </ul>
    </div>
</template>

<script>
export default {
  data () {
    return {
      title: 'vue to do list',
      items: [{
      label: 'aaa',
      isFinished: true
      },
       {
      label: 'bbb',
      isFinished: false
      }
      ],
      newItem: ''
    }
  },
  methods: {
                 toggleFinish: function(item){
          item.isFinished=!item.isFinished
      },
      addNew: function(){
          console.log(this.newItem); }
  }
}
</script>
<style>
.finished{
    color:#eee;
}
</style>

报错:

client.js?7955:105 [HMR] bundle has errors:
client.js?7955:107 [HMR] ./src/App.vue
  ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 8 space characters but found 6                                                         
 /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:19:7
        label: 'aaa',
         ^
  ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 8 space characters but found 6                                                         
/Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:20:7
        isFinished: true
         ^
  ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 6 space characters but found 7                                                         
/Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:22:8
         {
          ^

  ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 8 space characters but found 6                                                         
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:23:7
        label: 'bbb',
         ^

  ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 8 space characters but found 6                                                         
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:24:7
        isFinished: false
         ^

  ✘  http://eslint.org/docs/rules/no-mixed-spaces-and-tabs     Mixed spaces and tabs                                                                                          
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:31:2
                   toggleFinish: function(item){
       ^

  ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 4 space characters but found 1                                                         
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:31:6
                   toggleFinish: function(item){
                    ^

  ✘  http://eslint.org/docs/rules/space-before-function-paren  Missing space before function parentheses                                                                      
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:31:28
                   toggleFinish: function(item){
                                          ^

  ✘  http://eslint.org/docs/rules/space-before-blocks          Missing space before opening brace                                                                             
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:31:34
                   toggleFinish: function(item){
                                                ^

  ✘  http://eslint.org/docs/rules/no-mixed-spaces-and-tabs     Mixed spaces and tabs                                                                                          
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:32:2
            item.isFinished=!item.isFinished
    ^

  ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 3 space characters but found 2                                                         
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:32:5
            item.isFinished=!item.isFinished
             ^

  ✘  http://eslint.org/docs/rules/space-infix-ops              Infix operators must be spaced                                                                                 
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:32:20
            item.isFinished=!item.isFinished
                            ^

  ✘  http://eslint.org/docs/rules/no-mixed-spaces-and-tabs     Mixed spaces and tabs                                                                                          
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:33:2
        },
    ^

  ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 1 space character but found 2                                                          
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:33:4
        },
         ^

  ✘  http://eslint.org/docs/rules/no-mixed-spaces-and-tabs     Mixed spaces and tabs                                                                                          
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:34:2
        addNew: function(){
    ^

  ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 4 space characters but found 2                                                         
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:34:4
        addNew: function(){
         ^

  ✘  http://eslint.org/docs/rules/space-before-function-paren  Missing space before function parentheses                                                                      
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:34:20
        addNew: function(){
                         ^

  ✘  http://eslint.org/docs/rules/space-before-blocks          Missing space before opening brace                                                                             
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:34:22
        addNew: function(){
                           ^

  ✘  http://eslint.org/docs/rules/no-mixed-spaces-and-tabs     Mixed spaces and tabs                                                                                          
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:35:2
            console.log(this.newItem); }
    ^

  ✘  http://eslint.org/docs/rules/brace-style                  Closing curly brace should be on the same line as opening curly brace or on the line after the previous block  
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:35:5
            console.log(this.newItem); }
             ^

  ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 4 space characters but found 2                                                         
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:35:5
            console.log(this.newItem); }
             ^

  ✘  http://eslint.org/docs/rules/semi                         Extra semicolon                                                                                                
  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:35:30
            console.log(this.newItem); }
                                      ^


✘ 22 problems (22 errors, 0 warnings)


Errors:
  10  http://eslint.org/docs/rules/indent
   5  http://eslint.org/docs/rules/no-mixed-spaces-and-tabs
   2  http://eslint.org/docs/rules/space-before-blocks
   2  http://eslint.org/docs/rules/space-before-function-paren
   1  http://eslint.org/docs/rules/semi
   1  http://eslint.org/docs/rules/brace-style
   1  http://eslint.org/docs/rules/space-infix-ops
  • 关注 | 3
  • 收藏 | 3
  •  评论
  • 邀请回答
  • 编辑
  • Translate
  •  

蓝with黑  459

2016-09-25 提问

默认排序时间排序

2 个回答

答案对人有帮助,有参考价值3答案没帮助,是错误的答案,答非所问


已采纳

因为你设置了eslint,如果你不想有规范的js代码,可以重新初始化关掉eslint。
Use ESLint to lint your code? (Y/n) 这一步选no

如果你想有良好的规范,其实错误已经很清晰,大多数就是缩进不规范,分号不需要等原因,很容易解决的。写多了就成习惯了。

  •  评论 · 2
  • 赞赏
  • Translate
  • 编辑

airyland  5.6k

2016-09-25 更新

答案对人有帮助,有参考价值3答案没帮助,是错误的答案,答非所问

在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、付费专栏及课程。

余额充值