How to use jade mixins on client side

南笙酒味 提交于 2019-12-13 13:18:32

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!