更多資源可以看這邊的文檔:
vs code格式化代碼的快捷鍵如下:https://stackoverflow.com/questions/29973357/how-do-you-format-code-in-visual-studio-code-vscode
On Windows Shift + Alt + F
On Mac Shift + Option + F
On Ubuntu Ctrl + Shift + I
但是自帶的格式化並不能滿足我的需求,這個時候,不得不說插件大法好。
下載指定的插件
1、代碼格式化為eslint風格(參考自這里)
需要插件:eslint
首先我們先打開Vscode,點擊上面的 文件(file)選項,在文件的界面中點擊 首先項(preferences) 這個選項,
在設置中添加:
"eslint.autoFixOnSave": true, "eslint.validate": [ "javascript", "javascriptreact", { "language": "html", "autoFix": true }, { "language": "vue", "autoFix": true } ],