什么是最好/最常用的格式化/缩进函数参数对象的方法

时间:2017-08-29 20:06:03

标签: javascript coding-style code-formatting

我想知道StackOverflow人群如何更喜欢缩进代码,以及如何缩进/格式化下面的代码。

  this.router.navigate([
  'search', {
  filters: btoa(JSON.stringify({
      author: uid,
      byLikes: -1,
      requireInteractions: true,
      limit: ContentListComponent.contentPerLoad
  }))}
  ]);

我真的找不到一个好看的好方法来让(),[],{}匹配。

2 个答案:

答案 0 :(得分:0)

 this.router.navigate([
     'search', {
         filters: btoa(JSON.stringify({
             author: uid,
             byLikes: -1,
             requireInteractions: true,
             limit: ContentListComponent.contentPerLoad
         }))
     }
 ]);

只需在新块开始时缩进。

如果你使用的是sublime-text,那么有一个名为JsFormat的好包,你可以让它运行一个文件,它会自动纠正意图问题(也做其他事情)。请在此处查看:https://github.com/jdc0589/JsFormat

答案 1 :(得分:0)

使用prettier,您无需担心如何格式化代码。

相关问题