stylus 知识点

  • 循环的范围可以用两个小数点..表示,如(1..10)就是从1到10,并且包括1和10
    for in 的循环范围写法:
for index in 1 2 3

等价于:

$li_length = 3
for index in (1..$li_length)
  • 要拼接变量跟字符串,就必须使用大括号{},例如a.level-{$num}
    使用变量,也必须使用大括号。

  • stylus中数组包含对象,并遍历:
    注意:数组的元素不能换行

items = ({'left':10px,'top':10px}) ({'left':20px,'top':20px}) ({'left':30px,'top':30px}) ({'left':40px,'top':40px})
ul.iterator3
    for item, index in items
        li:nth-child({index+1}) a
            for name, value in item
                {name} value
原文地址:https://www.cnblogs.com/cag2050/p/7487844.html