问题
We can compile jade template as an anonymous function and call it when we need to render it on client side. What about mixins?
mixin:
mixin tiny(text)
button.tiny #{text}
回答1:
You can use them like this:
Declare your mixin somewhere, then use +
to call it when you want and pass the parameters in.
mixin person(name) // Declare
li.name= name
ul
+person('cat') // User
+person('dog')
+person('pig')
In your example
mixin tiny(text) // Declare
button.tiny= text
+tiny('text') // Use
来源:https://stackoverflow.com/questions/18958302/how-to-use-jade-mixins-on-client-side