使用Ember的动作帮助器,绑定属性是设置CSS样式的唯一方法吗? [英] With Ember's action helper, is bind-attr the only way to set CSS styles?

查看:70
本文介绍了使用Ember的动作帮助器,绑定属性是设置CSS样式的唯一方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不赞成使用Ember.Button视图(带有最新的Ember干线版本),而推荐使用动作帮助器,有没有一种方法可以设置动作帮助器的父HTML元素的静态/不变CSS样式(是否该元素是按钮,链接等),而不会绑定/覆盖那些静态CSS样式?也就是说,

With the deprecation of the Ember.Button view (w/ recent Ember trunk version) in favor of the action helper, is there a way to set the static/unchanging CSS styling of the action helper's parent HTML element (whether that element is a button, link, etc.) without those static CSS styles being bonked/overwritten? That is,


  • 使用旧的Ember.Button和#view我们可以同时传递class(用于静态CSS样式)和classBinding(用于动态样式)和静态样式不会受到动态样式的影响。

  • 但是使用新的动作帮助器,classBinding似乎不起作用。 bind-attr确实可以工作,但是为bind-attr之外的那个元素指定的任何CSS类都将被bind-attr class = foo规范覆盖。

  • 因此,唯一的方法我发现使用动作助手可以在元素上保持静态CSS样式,即指定一个字符串属性(在相关的Ember View中),以指定所需的CSS静态样式。例如{{bind-attr class = App.TheView.isActive App.TheView.cssStyles}}这很不雅/有漏洞。

谢谢

推荐答案

您还可以在中混合使用静态样式和动态样式。 {{bind-attr}} ,像这样:

{{bind-attr class=":staticStyle view.someProperty:dynamicStyle}}

这篇关于使用Ember的动作帮助器,绑定属性是设置CSS样式的唯一方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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