简体   繁体   English

如何在 vs 代码中启用更漂亮的自动关闭标签?

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

I want to enable auto close empty tag with Prettier in Visual Studio Code v 1.37.1.我想在 Visual Studio Code v 1.37.1 中使用 Prettier 启用自动关闭空标签。

I want this:我要这个:

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

from this:由此:

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

Anyone knows where to enable it in Prettier or with any other extension ??任何人都知道在哪里可以在 Prettier 或任何其他扩展中启用它?

I had problem with emmet from vs code.我在 vs 代码中遇到了 emmet 问题。 When I set this to html my img tags were looking like this:当我将其设置为 html 时,我的 img 标签如下所示:

<img src='' alt=''> 

And I couldn't save document without having a prettier error.而且我无法在没有更漂亮错误的情况下保存文档。

After set this in setting.json in vscode:在 vscode 中的 setting.json 中设置后:

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

When I write img and press tab, I'm getting this:当我写img并按 tab 时,我得到了这个:

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

And divs stays like they should look like:并且 div 保持它们应有的样子:

<div></div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM