How to use jade mixins on client side

2019-06-27 12:07发布

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}

标签: pug
1条回答
做自己的国王
2楼-- · 2019-06-27 13:09

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
查看更多
登录 后发表回答