相关疑难解决方法(0)

更漂亮的格式化配置

我正在努力为 Angular HTML 组件配置 Prettier 格式。我尝试了不同的配置覆盖,但我无法得到我想要的。

默认情况下,在 VS Code + Prettier 上,以下标记:

<ng-container *ngIf="emailRef.hasError('email')">A valid email address must be used</ng-container>
Run Code Online (Sandbox Code Playgroud)

被格式化为(因为行长):

<ng-container *ngIf="emailRef.hasError('email')"
  >A valid email address must be used</ng-container
>
Run Code Online (Sandbox Code Playgroud)

我一点都不喜欢。我不希望 Prettier 像那样拆分标签。我宁愿:

<ng-container *ngIf="emailRef.hasError('email')">
  A valid email address must be used
</ng-container>
Run Code Online (Sandbox Code Playgroud)

有谁知道如何覆盖其默认行为?当使用多个属性时,我可以使用默认格式,例如:

<input
  id="email"
  name="email"
  type="email"
  email
  required
  [(ngModel)]="email"
  #emailRef="ngModel"
/>
Run Code Online (Sandbox Code Playgroud)

html visual-studio-code angular prettier

6
推荐指数
2
解决办法
2385
查看次数

标签 统计

angular ×1

html ×1

prettier ×1

visual-studio-code ×1