手写笔查找哈希名称

时间:2015-10-02 08:19:02

标签: css hash lookup stylus for-in-loop

有没有办法使用Stylus lookup函数在for-in循环中应用哈希?

$badge-photo-S   = {
  size: 36px
  font-size: 16px
} 
$badge-photo-XS  = {
  size: 32px
  font-size: 13px
}
.s-badge
  &-photo
    for each in S XS
      &--{each}
        {lookup('$badge-photo-'+each)}

它应该屈服于:

.s-badge-photo--S {
  width: 36px
  height: 36px;
  font-size: 16px;
} 

.s-badge-photo--XS {
  width: 32px
  height: 32px;
  font-size: 13px;
} 

但它提供了一个空输出。

1 个答案:

答案 0 :(得分:2)

您需要将lookup的结果保存到变量中,然后在{}内使用它:

$badge-photo-S   = {
  size: 36px
  font-size: 16px
} 
$badge-photo-XS  = {
  size: 32px
  font-size: 13px
}
.s-badge
  &-photo
    for each in S XS
      &--{each}
        hash = lookup('$badge-photo-'+each)
        {hash}