Stylus 'for' 循环:可以组合范围和单个值吗?
Stylus 'for' cycle: possible to combine range and single values?
是否可以在 Stylus 中为 for
循环同时使用范围值和单个值(组合)?
for item in range(2, 7) 14 33
li:nth-child({item})
color red
或
for item in 2..7 14 33
li:nth-child({item})
color red
该代码无效。它只能在使用范围或一组单个值时起作用。
不幸的是,Stylus在标准库中没有concat
这样的东西,只有push
,但是你可以很容易地写出来:
concat()
ret = ()
for item in arguments
push(ret, item)
ret
body
for i in concat(range(0, 5), 10, 55)
test: i
是否可以在 Stylus 中为 for
循环同时使用范围值和单个值(组合)?
for item in range(2, 7) 14 33
li:nth-child({item})
color red
或
for item in 2..7 14 33
li:nth-child({item})
color red
该代码无效。它只能在使用范围或一组单个值时起作用。
不幸的是,Stylus在标准库中没有concat
这样的东西,只有push
,但是你可以很容易地写出来:
concat()
ret = ()
for item in arguments
push(ret, item)
ret
body
for i in concat(range(0, 5), 10, 55)
test: i