【问题标题】:WebStorm Code Style Templates - TypeScriptWebStorm 代码样式模板 - TypeScript
【发布时间】:2018-03-09 08:15:26
【问题描述】:

目前基于我的 WebStorm IDE 中的 TypeScript 代码样式设置,Angular @Component 装饰器代码的格式如下:

@Component({
               selector: 'my-component',
               templateUrl: 'my.component.html',
               styleUrls: ['my.component.scss']
           })
export class MyComponent implements OnInit {

我想要的是它在执行自动格式化时是这样格式化的:

@Component({
    selector: 'my-component',
    templateUrl: 'my.component.html',
    styleUrls: ['my.component.scss']
})
export class MyComponent implements OnInit {

但是我找不到正确的设置。我在 WebStorm 设置中 Editor > Code Style > Typescript 下的 Tabs and Indents 选项卡上有以下设置:

【问题讨论】:

  • 这是“包装和大括号”,不是吗?
  • @jonrsharpe 感谢您为我指明正确的方向。关键是确保未选中“环绕和大括号”选项卡上的“方法调用参数 > 多行对齐”

标签: angular typescript webstorm


【解决方案1】:

感谢@jonrsharpe 为我指明了正确的方向,我已经设法解决了这个问题...

  1. 在 WebStorm 中转到 文件 > 设置,然后转到 编辑器 > 代码样式 > 打字稿

  2. 点击环绕和大括号标签

  3. 确保未选中方法调用参数 > 多行复选框时对齐:

【讨论】:

    猜你喜欢
    • 2015-03-15
    • 2019-01-12
    • 2016-10-16
    • 1970-01-01
    • 1970-01-01
    • 2022-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多