【问题标题】:Getting the index of a key in Stylus在 Stylus 中获取键的索引
【发布时间】:2015-12-31 07:18:16
【问题描述】:

SASS 有一个内置的索引函数,它返回数组中的键位置。我一直在寻找几个小时,看看 Stylus 是否有任何类似的功能,但到目前为止还没有找到任何东西。有谁知道 Stylus 中有这样的功能或使用 Stylus Javascript API 实现类似功能的方法?

例如,我试图在 Stylus 中重新创建这个 Bootstrap 函数:

grid-breakpoints := {
  xs: 0,
  sm: 544px,
  md: 768px,
  lg: 992px,
  xl: 1200px
}

@function breakpoint-next($name, $breakpoints: $grid-breakpoints, $breakpoint-names: map-keys($breakpoints)) {
  $n: index($breakpoint-names, $name);
  @return if($n < length($breakpoint-names), nth($breakpoint-names, $n + 1), null);
}

【问题讨论】:

    标签: javascript node.js stylus


    【解决方案1】:

    我在 Stylus 存储库的问题部分提出了这个问题,并很快从其中一位主要贡献者那里得到了答案。这是问题https://github.com/stylus/stylus/issues/2077的链接。

    【讨论】:

      猜你喜欢
      • 2011-02-10
      • 2015-02-27
      • 1970-01-01
      • 1970-01-01
      • 2014-05-18
      • 2012-05-23
      • 1970-01-01
      • 2019-10-01
      • 2019-03-27
      相关资源
      最近更新 更多