vue在vscode中的配置篇

1,379 阅读1分钟

插件

  • color-highlight

可以查看色值对应的颜色效果,css必备

  • GitLens

git历史,代码维护的跟踪神器

  • vutur

vue语法高亮

  • eslint

代码规范检测,结合打包工具的eslint使用不错

  • Auto Rename Tag

标签重命名

  • Auto Close Tag

标签相关

  • git-commit-lint-vscode

git提交规范,非常推荐

配置篇

{
    /** 新版本配置(1.4及以上) **/
	//autoFixedOnSave 设置已废弃,采用如下新的设置
	"editor.codeActionsOnSave": {
	  "source.fixAll.eslint": true
	},
	"eslint.format.enable": true,
	//autoFix默认开启,只需输入字符串数组即可
	"eslint.validate": ["javascript", "vue", "html"],

	/** 兼容老版本配置 **/
	
	//配置eslint
	"eslint.autoFixOnSave": true,  //  启用保存时自动修复,默认只支持.js文件
	"eslint.validate": [
	   "javascript",  //  用eslint的规则检测js文件
	   {
	     "language": "vue",   // 检测vue文件
	     "autoFix": true   //  为vue文件开启保存自动修复的功能
	   },
	   {
	     "language": "html",
	     "autoFix": true
	   }
	 ],
}

终端使用code命令

VSCode 提供 code 命令直接从命令行中打开文件目录,此时需要先安装 code 命令。

  • 首先打开 VSCode

  • 使用 command + shift + p (注意window 下使用 ctrl + shift + p ) 然后搜索code,选择 install 'code' command in path。

总结

vscode配置后续会持续补充