[英]How to configure prettier such that it formats jsx attributes in multiple lines in VSCODE?
我想要這個:
<input
id="inputForEmail"
type="email"
className="form-control"
aria-describedby="Enter email address"
placeholder="Enter email address"
/>
與此相反:
<input id="inputForEmail" type="email" className="form-control" aria-describedby="Enter email address" placeholder="Enter email address" />
VSCode 現在添加了一種方法來執行此操作。 您可以編輯 settings.json (ctrl+shift+p),然后添加以下內容以獲得所需的效果:
"html.format.wrapAttributes": "force-aligned"
- 或者 -
"html.format.wrapAttributes": "force"
force-aligned 還將添加縮進以將其與打開標記的行上的屬性對齊。
或者
您可以轉到編輯器中的擴展並搜索 prettier,然后安裝它。 然后您無需設置任何內容,只需轉到您的代碼並按 shift + i 或 shift+alt+f 即可。 干杯! 你的代碼格式很好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.