vue单元测试相关问题总结

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

 

  1 client.js?7955:105 [HMR] bundle has errors:
  2 client.js?7955:107 [HMR] ./src/App.vue
  3   ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 8 space characters but found 6                                                         
  4  /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:19:7
  5         label: 'aaa',
  6          ^
  7   ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 8 space characters but found 6                                                         
  8 /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:20:7
  9         isFinished: true
 10          ^
 11   ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 6 space characters but found 7                                                         
 12 /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:22:8
 13          {
 14           ^
 15 
 16   ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 8 space characters but found 6                                                         
 17   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:23:7
 18         label: 'bbb',
 19          ^
 20 
 21   ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 8 space characters but found 6                                                         
 22   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:24:7
 23         isFinished: false
 24          ^
 25 
 26   ✘  http://eslint.org/docs/rules/no-mixed-spaces-and-tabs     Mixed spaces and tabs                                                                                          
 27   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:31:2
 28                    toggleFinish: function(item){
 29        ^
 30 
 31   ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 4 space characters but found 1                                                         
 32   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:31:6
 33                    toggleFinish: function(item){
 34                     ^
 35 
 36   ✘  http://eslint.org/docs/rules/space-before-function-paren  Missing space before function parentheses                                                                      
 37   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:31:28
 38                    toggleFinish: function(item){
 39                                           ^
 40 
 41   ✘  http://eslint.org/docs/rules/space-before-blocks          Missing space before opening brace                                                                             
 42   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:31:34
 43                    toggleFinish: function(item){
 44                                                 ^
 45 
 46   ✘  http://eslint.org/docs/rules/no-mixed-spaces-and-tabs     Mixed spaces and tabs                                                                                          
 47   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:32:2
 48             item.isFinished=!item.isFinished
 49     ^
 50 
 51   ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 3 space characters but found 2                                                         
 52   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:32:5
 53             item.isFinished=!item.isFinished
 54              ^
 55 
 56   ✘  http://eslint.org/docs/rules/space-infix-ops              Infix operators must be spaced                                                                                 
 57   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:32:20
 58             item.isFinished=!item.isFinished
 59                             ^
 60 
 61   ✘  http://eslint.org/docs/rules/no-mixed-spaces-and-tabs     Mixed spaces and tabs                                                                                          
 62   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:33:2
 63         },
 64     ^
 65 
 66   ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 1 space character but found 2                                                          
 67   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:33:4
 68         },
 69          ^
 70 
 71   ✘  http://eslint.org/docs/rules/no-mixed-spaces-and-tabs     Mixed spaces and tabs                                                                                          
 72   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:34:2
 73         addNew: function(){
 74     ^
 75 
 76   ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 4 space characters but found 2                                                         
 77   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:34:4
 78         addNew: function(){
 79          ^
 80 
 81   ✘  http://eslint.org/docs/rules/space-before-function-paren  Missing space before function parentheses                                                                      
 82   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:34:20
 83         addNew: function(){
 84                          ^
 85 
 86   ✘  http://eslint.org/docs/rules/space-before-blocks          Missing space before opening brace                                                                             
 87   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:34:22
 88         addNew: function(){
 89                            ^
 90 
 91   ✘  http://eslint.org/docs/rules/no-mixed-spaces-and-tabs     Mixed spaces and tabs                                                                                          
 92   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:35:2
 93             console.log(this.newItem); }
 94     ^
 95 
 96   ✘  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  
 97   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:35:5
 98             console.log(this.newItem); }
 99              ^
100 
101   ✘  http://eslint.org/docs/rules/indent                       Expected indentation of 4 space characters but found 2                                                         
102   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:35:5
103             console.log(this.newItem); }
104              ^
105 
106   ✘  http://eslint.org/docs/rules/semi                         Extra semicolon                                                                                                
107   /Users/apple/Desktop/VUEJS/vuePro/myvueProject01/src/App.vue:35:30
108             console.log(this.newItem); }
109                                       ^
110 
111 
11222 problems (22 errors, 0 warnings)
113 
114 
115 Errors:
116   10  http://eslint.org/docs/rules/indent
117    5  http://eslint.org/docs/rules/no-mixed-spaces-and-tabs
118    2  http://eslint.org/docs/rules/space-before-blocks
119    2  http://eslint.org/docs/rules/space-before-function-paren
120    1  http://eslint.org/docs/rules/semi
121    1  http://eslint.org/docs/rules/brace-style
122    1  http://eslint.org/docs/rules/space-infix-ops
View Code

因为你设置了eslint,如果你不想有规范的js代码,可以重新初始化关掉eslint。

Use ESLint to lint your code? (Y/n) 这一步选no

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

或者

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

...(config.dev.useEslint ? [createLintingRule()] : []),

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

转载于:https://www.cnblogs.com/tiankafei/p/10732582.html

你可能感兴趣的:(vue单元测试相关问题总结)