Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 什么';s[]、@each、content和<;arrayName>;在恩伯斯?_Javascript_Ember.js_Properties - Fatal编程技术网

Javascript 什么';s[]、@each、content和<;arrayName>;在恩伯斯?

Javascript 什么';s[]、@each、content和<;arrayName>;在恩伯斯?,javascript,ember.js,properties,Javascript,Ember.js,Properties,我四处查看了一下,但找不到任何关于以下各项之间实际差异的好文档: Ember.Object.extend({ // ... myProperty1:function(){/*…*/}.property('myArray'), myProperty2:function(){/*…*/}.property('myArray.content'), myProperty3:function(){/*…*/}.property('myArray.[]'), myProperty4:function(){/

我四处查看了一下,但找不到任何关于以下各项之间实际差异的好文档:

Ember.Object.extend({
// ...
myProperty1:function(){/*…*/}.property('myArray'),
myProperty2:function(){/*…*/}.property('myArray.content'),
myProperty3:function(){/*…*/}.property('myArray.[]'),
myProperty4:function(){/*…*/}.property('myArray.@each')
});
我知道
.content
似乎是属性数组的内部存储,如果这恰好是
PromiseArray
,则可能不可用。我还了解到,
@each
不会以这种方式使用,而是主要用于访问
ProxyArray
,该数组通过映射该数组中每个元素的内部属性生成结果

除了这些细微的差别,它们的作用似乎几乎相同。但是
myArray
myArray.[]
呢?和其他人相比,他们呢

Ember.Object.extend({
  // ...

  // Updates if myArray is set to a new value using .set
  myProperty1: function() { /* ... */ }.property('myArray'),

  // Updates if myArray is an Ember Object (like an ArrayController)
  // and its 'content' property is set to a new value using
  // .set('content', newArray) or .replaceContent(...)
  // which can also happen implicitly
  // Also note that for an ArrayController 'content' is an alias of 'model'
  myProperty2: function() { /* ... */ }.property('myArray.content'),

  // Updates if myArray is an Ember Array or ArrayProxy or MutableEnumerable
  // and it is 'mutated' using myArray.addObject(s), myArray.removeObject,
  // myArray.popObject, myArray.shiftObject, myArray.pushObject(s), etc.
  myProperty3: function() { /* ... */ }.property('myArray.[]'),

  // Updates if myArray is an Ember Array or ArrayProxy and one of it's
  // elements is set to a new value using .set or .replace
  // such as this.set('myArray.firstObject', 10) or
  // this.get('myArray').replace(2, 1, [10]);
  myProperty4: function() { /* ... */ }.property('myArray.@each')
});
我还要注意,如果您忘记使用Ember的方法之一,而只是使用简单的JavaScript更新数组,如下所示:

this.myArray = [];

这些计算属性都不会更新。

答案令人印象深刻。直截了当,明白无误。非常感谢你。