解决方案是将这些行添加到settings.json 文件中:
"emmet.syntaxProfiles": {
"svelte": "html",
"typescript": "html",
"javascriptreact": "html",
"typescriptreact": "html",
"html": {
"attr_quotes": "single",
"self_closing_tag": true,
},
},
"emmet.includeLanguages": {
"svelte": "html",
"typescript": "html",
"javascriptreact": "html",
"typescriptreact": "html",
//"javascript": "javascriptreact"
},
(当然,您只需要包含您实际使用的语言。例如,如果您不使用 svelte(为什么不使用??)或 typescript,则不要使用它们)
额外:
如果您还想知道如何使用 Tab 键来扩展 Emmet 缩写,请同时添加以下行:
"emmet.triggerExpansionOnTab": true,
因此:对于您使用 Emmet 的每种语言,您希望将该语言类型映射到 "html",然后在 "html" 键中,告诉它使用 "attr_quotes": "single"
我在哪里进行此更改?
根据您的平台,用户设置文件 (settings.json) 位于此处:
Windows: %APPDATA%\Code\User\settings.json
macOS : $HOME/Library/Application Support/Code/User/settings.json
Linux : $HOME/.config/Code/User/settings.json
在 VSCode 中打开 settings.json 文件的另一种方法:
一个。 Ctrl + ,(逗号)打开设置
湾。工作台
C。设置编辑器
e.在顶部的搜索框中,输入emmet.
F。在左侧,单击工作台,然后单击外观
G。点击右侧链接:在 settings.json 中编辑
参考资料:
https://www.smashingmagazine.com/2021/06/custom-emmet-snippets-vscode/
Where are the default Emmet settings in Visual Studio Code?
https://github.com/Microsoft/vscode/issues/32496
https://www.smashingmagazine.com/2021/06/custom-emmet-snippets-vscode/
https://sudolabs.io/blog/tips-to-use-vscode-more-efficiently