html - 更漂亮的格式化配置
问题描述
我正在努力为 Angular HTML 组件配置 Prettier 格式。我尝试了不同的配置覆盖,但我无法得到我想要的。
默认情况下,在 VS Code + Prettier 上,以下标记:
<ng-container *ngIf="emailRef.hasError('email')">A valid email address must be used</ng-container>
被格式化为(因为行长):
<ng-container *ngIf="emailRef.hasError('email')"
>A valid email address must be used</ng-container
>
我一点也不喜欢。我不希望 Prettier 像那样拆分标签。我更喜欢:
<ng-container *ngIf="emailRef.hasError('email')">
A valid email address must be used
</ng-container>
有谁知道如何覆盖其默认行为?当使用多个属性时,我可以使用默认格式,例如:
<input
id="email"
name="email"
type="email"
email
required
[(ngModel)]="email"
#emailRef="ngModel"
/>
解决方案
对我有用的是在内容和开始和结束标签之间添加一个空格:
<ng-container *ngIf="emailRef.hasError('email')"> A valid email address must be used </ng-container>
使用空格,更漂亮的格式正确
推荐阅读
- azure - 无法发布 Azure 数据工厂管道更改
- windows - 如果循环在循环窗口批处理文件中不起作用
- asp.net-mvc - 如何将参数与模型一起传递?
- tensorflow - 谷歌云 TPU:NotImplementedError:TPU 计算中不支持非资源变量
- angular - 当字符在文本框中时隐藏内容
- django - 类型错误:__init__() 接受 1 个位置参数,但给出了 2 个。我已经看到了许多针对此错误的解决方案,但没有一个与我的情况相符
- pdf - 检测文件夹中的 PDF 文件并检查它是否打开
- arduino - IP 数据包处理 - ARDUINO
- sql - 在 BigQuery 上运行过去 30 天的 Sum
- ios - 将可平移的 UIView 保持在边界内