用VSCode写Vue要用到的配置

[本文出自天外归云的博客园]

文件-首选项-设置-打开settings.json-用户设置区域填写:

{
  "workbench.colorTheme": "Monokai",
  "workbench.editor.enablePreview": false, // 打开文件不覆盖
  "search.followSymlinks": false, // 关闭rg.exe进程
  "editor.minimap.enabled": false, // 关闭快速预览
  "files.autoSave": "afterDelay", // 打开自动保存
  "editor.lineNumbers": "on", // 开启行数提示
  "editor.quickSuggestions": {
    // 开启自动显示建议
    "other": true,
    "comments": true,
    "strings": true
  },
  "editor.tabSize": 2, // 为了符合eslint的两个空格间隔原则
  "files.associations": {
    "*.vue": "vue"
  },
  "eslint.autoFixOnSave": true,
  "eslint.options": {
    "extensions": [".js", ".vue"]
  },
  "prettier.eslintIntegration": true, // 让prettier使用eslint的代码格式进行校验
  "prettier.semi": true, // 去掉代码结尾的分号
  "prettier.singleQuote": true, // 使用单引号替代双引号
  "javascript.format.insertSpaceBeforeFunctionParenthesis": true, // 让函数(名)和后面的括号之间加个空格
  "vetur.format.defaultFormatter.html": "js-beautify-html", // 格式化.vue中html
  "vetur.format.defaultFormatter.js": "vscode-typescript", // 让vue中的js按编辑器自带的ts格式进行格式化
  "vetur.format.defaultFormatterOptions": {
    "js-beautify-html": {
      "wrap_attributes": "force-aligned" // 属性强制折行对齐
    }
  },
  "eslint.validate": [
    "javascript",
    {
      "language": "vue",
      "autoFix": true
    },
    {
      "language": "html",
      "autoFix": true
    }
  ],
  "search.exclude": {
    "**/node_modules": true,
    "**/bower_components": true,
    "**/dist": true
  },
  "emmet.syntaxProfiles": {
    "javascript": "jsx",
    "vue": "html",
    "vue-html": "html"
  },
  "editor.fontSize": 22, // 编辑器文字大小
  "window.zoomLevel": 0
}

之后在VSCode中就可以通过 ctrl+shift+f 来按eslint格式进行格式化了。

 

posted @ 2018-10-19 18:05  天外归云  阅读(1240)  评论(0编辑  收藏  举报