统一前端代码风格

首先设置vscode的setting.json

{
  "eslint.autoFixOnSave": true,
  "eslint.validate": [
    "javascript",
    {
      "language": "vue",
      "autoFix": true
    },
    "html",
    "vue"
  ],
  // #每次保存的时候自动格式化
  "editor.formatOnSave": true,
  "vetur.format.defaultFormatter.js": "prettier",
  "vetur.format.defaultFormatterOptions": {
    "prettier": {
      // Prettier option here
      "tabWidth": 2,
      "semi": false,
      "singleQuote": true
    }
  },
  "files.autoSave": "onFocusChange"
}

其次安装vetur,eslint插件

 安装eslint-plugin-vue

yarn add eslint-plugin-vue --dev

 更改.eslinttrc.js 添加vue选项

猜你喜欢

转载自blog.csdn.net/coderMozart/article/details/85070951