0

私が作成している次のオブジェクトがあります。

Ember.Object.create({
  value: function() {
    return 'text';
  }.property()
});

しかし、私はhas no method 'property'エラーが発生しています。property理由はわかりませんが、すべての機能で利用できると思いました。

4

3 に答える 3

1

If you open your JavaScript console you'll notice the following error:

Uncaught Error: assertion failed: Ember.Object.create no longer supports defining computed properties.

Try this instead:

App.Object = Ember.Object.extend({
  value: function() {
    return 'text';
  }.property()
});

alert(App.Object.create().get('value'));

In Ember, you should be creating objects, not instances. If you find yourself creating instances of objects like this, then you're probably doing something wrong. There are of course cases where you'll need to create Ember.Objects straight away, but for them to have computed properties, and to call _super? I can't think of any valid cases for that, and since they've since been @deprecated, you'll have to find alternative solutions. Better solutions.

于 2013-02-09T20:52:18.177 に答える
0

プロトタイプ拡張機能を無効にしていたことがわかりました。

http://emberjs.com/guides/configuring-ember/disabling-prototype-extensions/

于 2013-02-09T21:39:43.393 に答える
-1

モデルのドキュメント例を使用してみてください:http://emberjs.com/api/classes/Ember.ComputedProperty.html#method_property

于 2013-02-09T20:48:34.637 に答える