VSCode Prettier 以一种奇怪的方式格式化 HTML(下一行大于符号) [英] VSCode Prettier formats HTML in an odd way (greater-than-symbol on next line)

查看:56
本文介绍了VSCode Prettier 以一种奇怪的方式格式化 HTML(下一行大于符号)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从今天开始,安装了 Prettier 扩展的 VSCode 以一种非常奇怪的方式格式化了我的 HTML.例如:

Since today VSCode with installed Prettier Extension formats my HTML in a really odd way. For example:

<button
  class="btn btn-secondary mr-2"
  (click)="updateEditState(EditState.preview)"
  *ngIf="!(preview | async)"
>
  <ng-container i18n="AppPreviewEditButton|Enables the Preview mode of the page@@AppPreviewButton"
    >Preview</ng-container
  >
</button>
<button class="btn btn-secondary mr-2" (click)="updateEditState(EditState.edit)" *ngIf="!(edit | async)">
  <ng-container i18n="AppPreviewEditButton|Enables the Edit mode of the page@@AppEditButton"
    >Edit</ng-container
  >
</button>

注意新行中的 >.有没有其他人遇到同样的情况并有解决方案?

Notice the > on new lines. Did somebody else experienced the same and has a solution?

推荐答案

您应该在项目的 .prettierrc 文件中设置 "htmlWhitespaceSensitivity":"ignore".

You should set "htmlWhitespaceSensitivity": "ignore" in your project's .prettierrc file.

https://prettier.io/docs/en/options.html#html-whitespace-敏感性

这篇关于VSCode Prettier 以一种奇怪的方式格式化 HTML(下一行大于符号)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆