简体   繁体   English

在 VS 代码中更漂亮,将属性拆分为多行(打印宽度不适用于 html)Angular

[英]Prettier in VS code splitting attributes onto multiple lines ( print width doesn't work for html ) Angular

I've searched a lot about it and tried so much solutions,我已经搜索了很多关于它并尝试了很多解决方案,

I'm using Angular when formatting html with prettier it's quite ugly because it wraps every single attribute to a new line eg:我在用 prettier 格式化 html 时使用 Angular 它非常难看,因为它将每个属性都包装到一个新行中,例如:

   <button
      pButton
      class="btn"
      type="button"
      label="Add Item(s)"
      (click)="handleClick()"
    ></button>
  • Print Width is 250 everywhere打印宽度到处都是 250

在此处输入图像描述

  • added .prettierrc.json file with {"printWidth": 100}添加.prettierrc.json文件{"printWidth": 100}
  • Single Attribute Per Line isn't checked未选中每行单个属性

在此处输入图像描述

Important thing to note is that prettier is applying printWidth 80 something like built-in because I'm sure that it's not set in any settings by user, I have some attributes that are two per line when they quite little in space eg:需要注意的重要一点是 prettier 正在应用 printWidth 80 之类的东西,因为我确信它没有被用户设置在任何设置中,我有一些属性,当它们的空间很小时,每行两个,例如:

 <div class="p-col-2" style="float: left">
     {{ "modules.user.orderdisplay.quantity" | translate }}
 </div>

You should also check for.editorconfig file - if it is present prettier will use it's values.您还应该检查 .editorconfig 文件——如果它存在,prettier 将使用它的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM