如何在 vs code 中使用 prettier 启用自动关闭标签?

How to enable auto close tag with prettier in vs code?

我想在 Visual Studio 代码 v 1.37.1 中使用 Prettier 启用自动关闭空标签。

我想要这个:

<img src='/logo.svg' alt='' />
<div />

来自这个:

<img src='/logo.svg' alt=''>
<div></div>

任何人都知道在 Prettier 或任何其他扩展中在哪里启用它??

我在 vs code 中遇到了 emmet 问题。当我将其设置为 html 时,我的 img 标签看起来像这样:

<img src='' alt=''> 

而且我无法在没有更漂亮的错误的情况下保存文档。

在 vscode 中的 setting.json 中设置后:

"emmet.includeLanguages": {
        "javascript": "javascriptreact"
    },

当我输入 img 并按 Tab 键时,我得到了这个:

<img src='' alt='' />

并且 div 保持应有的样子:

<div></div>