如何在客户端使用 jade mixins [英] How to use jade mixins on client side

查看:58
本文介绍了如何在客户端使用 jade mixins的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以将 jade 模板编译为匿名函数,并在需要在客户端渲染时调用它.混入呢?

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 tiny(text)
      button.tiny #{text}

推荐答案

你可以这样使用它们:

在某处声明你的mixin,然后在需要时使用+调用它并传入参数.

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')

在你的例子中

 mixin tiny(text) // Declare
      button.tiny= text

 +tiny('text') // Use

这篇关于如何在客户端使用 jade mixins的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆