vscode 开发 vue 时环境准备和配置

vscode 安装ESlint 插件、Vetur、Prettier-Code formatter
Javascript Standard Style ;

需要进行配置,

{
    "editor.fontSize": 18,
    "editor.formatOnSave": false, // 为了避免data () ,data后面的空格save时被删除
    "eslint.options": {
        "extensions": [
            ".js",
            ".vue"
        ]
    },
   "eslint.validate": [
        "javascript",
        "javascriptreact",
        {
            "language": "vue",
            "autoFix": true
        }
    ], 

    "prettier.eslintIntegration": true,  // prettier 按照eslint进行格式化
    "javascript.format.insertSpaceBeforeFunctionParenthesis": true
}

以上的配置的缺点是,右键格式化时不会自动在函数名和()之间加入一个空格。

例如下面代码data后面的空格无法在格式化时自动插入

export default {
  data () {
    return {
      theme2: 'dark'
    }
  }
}

添加下面配置后,在保存时,会自动在函数名和()之间插入一个空格

"eslint.autoFixOnSave": true

猜你喜欢

转载自blog.csdn.net/looyo/article/details/80458274