【踩坑指南】Vue Webpack配置踩坑

問題1:expected indentation of 0 spaces but found 2 .

在通過 vue-cli創建vue項目時一股腦回車的後果。。選擇了usesEslint規範,從而導致不能隨意進行Formmat排版

因此會提示如下報錯:
expected indentation of 0 spaces but found 2 .

解決方案:
1.打開 /config/index.js文件 ,找到:

	// Use Eslint Loader?
    // If true, your code will be linted during bundling and
    // linting errors and warnings will be shown in the console.
    
    // 將 true更改爲false即可
    useEslint: false,  

2.打開根目錄下的/.eslintrc.js文件,找到:

// add your custom rules here
  rules: {
    // allow async-await
    
    // 配置如下
    'generator-star-spacing': 'off',
    'indent': ['off', 0],

    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
  }

問題2:Missing space before function parentheses

函數括號前缺少空格,例如通過自動排版生成的代碼 data(){}會產生該警告。

解決方案:
打開根目錄下的/.eslintrc.js文件,找到:

// add your custom rules here
  rules: {
    // allow async-await
    
    // 配置如下
	"space-before-function-paren": 0,

    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
  }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章