[英]How to configure prettier such that it formats jsx attributes in multiple lines in VSCODE?
I would like this:我想要这个:
<input
id="inputForEmail"
type="email"
className="form-control"
aria-describedby="Enter email address"
placeholder="Enter email address"
/>
As opposed to this:与此相反:
<input id="inputForEmail" type="email" className="form-control" aria-describedby="Enter email address" placeholder="Enter email address" />
VSCode added a way to do this now. VSCode 现在添加了一种方法来执行此操作。 You can edit your settings.json (ctrl+shift+p) and then add the following for the desired effect:您可以编辑 settings.json (ctrl+shift+p),然后添加以下内容以获得所需的效果:
"html.format.wrapAttributes": "force-aligned"
--or-- - 或者 -
"html.format.wrapAttributes": "force"
force-aligned will also add indents to align it with the attribute on the line where tag was opened. force-aligned 还将添加缩进以将其与打开标记的行上的属性对齐。
OR或者
You can go to extensions in the editor and search for prettier then install it.您可以转到编辑器中的扩展并搜索 prettier,然后安装它。 Then you don't need to setting up anything just go to your code and press shift + i or shift+alt+f .然后您无需设置任何内容,只需转到您的代码并按 shift + i 或 shift+alt+f 即可。 Cheers!干杯! your code is nicely formatted.你的代码格式很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.