jichi

前言

使用vscode开发vue项目的时候,为了编码格式的统一化,使用eslint规范进行格式化。此时通过eslint插件可以实现对vue代码的自动格式化。

使用方式

在vscode的插件模块处,搜索eslint。找到下面的插件。

安装完成后,进行配置。
file --> preferences --> setting
找到eslint。

打开setting.json。
在里面配置如下代码:

{
  "eslint.options": {
    "extensions": [
      ".js",
      ".vue"
    ]
  },
  "eslint.validate": [
    "javascript",
    {
      "language": "vue",
      "autoFix": true
    },
    "html",
    "vue"
  ],
  "eslint.autoFixOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "eslint.codeAction.disableRuleComment": {},
  "eslint.alwaysShowStatus": true,
}

重启后,修改代码,当不符合es规范的时候,使用ctrl+s保存的时候,就自动修复了。

分类:

vue es6

技术点:

相关文章:

  • 2021-06-17
  • 2021-04-11
  • 2021-05-07
  • 2021-10-14
  • 2021-11-21
  • 2021-11-09
  • 2021-09-30
  • 2021-12-05
猜你喜欢
  • 2021-09-27
  • 2021-06-24
  • 2021-05-04
  • 2021-10-24
  • 2021-11-09
  • 2021-07-08
  • 2021-05-23
相关资源
相似解决方案