EmberJS:Ember数据绑定组件中的oneWay(EmberJS: Ember data binding oneWay in components)

我正在使用emberjs,我想在我的组件中的某些属性上实现单向绑定。

是否有任何方法可以直接将属性设置为组件中的单向绑定而不创建新属性?

例如,我想避免这样做:

export default Ember.Component.extend({ name: null, _name: Ember.computed.oneWay('name') });

I'm using emberjs and I would like to achieve a one way binding on some properties in my component.

Is there any way to set directly to a property to be one way binding in a component without creating a new property of that?

For example I want to avoid doing this:

export default Ember.Component.extend({ name: null, _name: Ember.computed.oneWay('name') });

最满意答案

有readOnly helper它提供只读单向绑定。 因此,每当您将name属性传递给component时,请使用此readOnly帮助程序以避免双向绑定。

{{comp-a name=(readonly name) }}

There is readOnly helper It provides read only one way binding. So whenever you pass name property to component, then make use of this readOnly helper to avoid two way binding.

{{comp-a name=(readonly name) }}

更多推荐