【发布时间】:2013-11-22 07:53:27
【问题描述】:
我在 Jade 中有以下 mixin:
mixin indicator(slide_to, active)
- active = active || '' // this is an ugly method to create a default value
li(class=active, data-target='#' + CAROUSEL_ID, data-slide-to=slide_to)
我这样称呼它:
+indicator(1)
+indicator(2, 'active')
我希望参数active 具有默认值''。我发现了我的代码示例中显示的丑陋的解决方法。在 Jade 中有没有更好的方法来做到这一点?
【问题讨论】:
-
据我所知:没有。
-
但是如果你想让这个类是空的,为什么不让它保持原样呢?如果您在未定义活动的情况下设置
class=active,则根本不会有任何类属性。 -
不,如果 active 没有设置,会有 class=undefined
标签: pug