英文:
How can I use Emmet abbreviations to add a value-less property to an element?
问题
I'm here to provide the translation you requested:
我正在尝试使用VS Code中的Emmet创建一些具有特定属性的元素。
以下Emmet正常工作,并产生良好的输出。
```css
input[type="password"]
扩展为
<input type="password"></input>
然而,如果我尝试为元素提供一个没有值的属性,它会添加一个字符串,有时是不正确的。
input[required]
扩展为
<input required="required"></input>
如何让Emmet只生成没有值的属性,像这样?
<input required></input>
我已经查阅了缩写的文档,但这个特定情况似乎没有列出。有人有什么想法吗?
<details>
<summary>英文:</summary>
I'm trying to create some elements using Emmet in VS Code, where those elements have specific properties.
The following Emmet works correctly, and produces good output.
```css
input[type="password"]
Expands to
<input type="password"></input>
However, if I try to give a value-less property to the element, it adds a string to it, which is sometimes incorrect.
input[required]
Expands to
<input required="required"></input>
How can I make Emmet only produce the property with no value, like this?
<input required></input>
I've had a look through the documentation for abbreviations and this particular case doesn't seem to be listed there. Does anyone have any ideas?
答案1
得分: 1
从谷歌搜索“github vscode issues emmet attribute without value
”,我找到了Emmet: compact boolean attributes won't work #32282,在那里我了解到了emmet.syntaxProfiles
设置。
尝试将以下内容放入您的settings.json文件:
"emmet.syntaxProfiles": {
"html": {
"compactBooleanAttributes": true
}
}
另请参阅https://docs.emmet.io/customization/syntax-profiles/和https://docs.emmet.io/customization/preferences/。
出于某种原因,还有另一种方法可以做到:
"emmet.preferences": {
"profile.allowCompactBoolean": true
},
英文:
From googling "github vscode issues emmet attribute without value
", I found Emmet: compact boolean attributes won't work
#32282, where I learned of the emmet.syntaxProfiles
setting.
Try putting the following in your settings.json file:
"emmet.syntaxProfiles": {
"html": {
"compactBooleanAttributes": true
}
}
See also https://docs.emmet.io/customization/syntax-profiles/ and https://docs.emmet.io/customization/preferences/.
For some reason there's another way to do it as well:
"emmet.preferences": {
"profile.allowCompactBoolean": true
},
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论