简体   繁体   中英

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.

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 ??

I had problem with emmet from vs code. When I set this to html my img tags were looking like this:

<img src='' alt=''> 

And I couldn't save document without having a prettier error.

After set this in setting.json in vscode:

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

When I write img and press tab, I'm getting this:

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

And divs stays like they should look like:

<div></div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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