有没有办法使用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;
}
但它提供了一个空输出。
答案 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}