【问题标题】:Adding conditional class to EmberJS handlebar element将条件类添加到 EmberJS 车把元素
【发布时间】:2015-09-10 03:14:58
【问题描述】:

我正在尝试使用 EmberJS 车把纹理元素并有条件地向它添加一个 css 类。代码如下所示:

{{textarea class={{if isBlue 'blue-css' 'green-css'}} }}

这不起作用。内部车把表达式按字面意思插入到 html 中,但我可以使用 html 文本区域:

<textarea class={{if isBlue 'blue-css' 'green-css'}} ></textarea>
如果有的话,我如何使用 EmberJS 车把表达式来做到这一点? 谢谢

【问题讨论】:

    标签: css ember.js handlebars.js


    【解决方案1】:

    你可以试试,

    {{textarea classNameBindings="isBlue:blue-css:green-css"}}
    

    这里解释docs

    【讨论】:

    • 谢谢。我对 EmberJS 还是很陌生,只是错过了它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-15
    • 2013-01-23
    • 1970-01-01
    相关资源
    最近更新 更多