我想制作一个Jade mixin,它会输出类似这样的内容
到目前为止,我已经做到了这一点,但是我无法弄清楚如何使其能够添加类(例如 'two'、'three' 等)。
<div class="progress__graph">
<div class="progress__bar two">
<p>Web Design 80%</p>
</div>
</div>
<div class="progress__graph">
<div class="progress__bar three">
<p>Web Design 80% </p>
</div>
</div>
到目前为止,我已经做到了这一点,但是我无法弄清楚如何使其能够添加类(例如 'two'、'three' 等)。
mixin progress(text)
.progress__graph
.progress__bar
p #{text}
&attributes
语法可以将一个对象展开为元素的属性。就像这里描述的那样:http://jade-lang.com/reference/attributes/#and-attributes。如果您需要多个属性,这会使事情变得更加容易。这是一个基于您的示例的示例:http://codepen.io/pure180/pen/AXyqBX - Daniel