我正在做一个用Ember.js制作的项目,我正在使用按钮的ember-paper插件,也使用Ember-intl插件来翻译我的应用程序(英语和法语)。
我有一个基本的HTML按钮,代码如下:
<button class={{if model.active "active"}} {{action "changeLocale" model.locale}}>{{model.locale}}</button>但是当我将ember-paper与这种代码一起使用时:
{{#paper-button accent=true}}Test{{/paper-button}}我找不到一种方法来添加if语句和操作。
{{if model.active "active"}} {{action "changeLocale" model.locale}}>你知道怎么做吗?
发布于 2019-03-28 12:49:23
工作Twiddle
1)您可以在{{#paper-button}}组件内部使用onClick选项调用您的action。
2)您可以使用disabled和accent布尔选项根据您的条件model.active设置true或false
{{#paper-button
onClick=(action "someAction")
accent=true
disabled=(unless model.active true)
accent=(if model.active true)
}}
Test
{{/paper-button}}https://stackoverflow.com/questions/55381762
复制相似问题