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/0/amazon-s3/2.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
Ember.js 余烬数组未更新模板_Ember.js_Ember Select - Fatal编程技术网

Ember.js 余烬数组未更新模板

Ember.js 余烬数组未更新模板,ember.js,ember-select,Ember.js,Ember Select,当您在控制器中更新数组而视图中未显示更新时(当页面最初加载时,更新工作时),可能的原因是什么 执行更新的我的操作: submit: function (foo) { let arr = this.get("baa"); arr.push(foo); this.set("items", arr); } 模板: {{view "select" content=items class="form-control"}} 推送的任何内容都不会反映在

当您在控制器中更新数组而视图中未显示更新时(当页面最初加载时,更新工作时),可能的原因是什么

执行更新的我的操作:

  submit: function (foo) {
      let arr = this.get("baa");
      arr.push(foo);
      this.set("items", arr);
    }
模板:

 {{view "select" content=items   class="form-control"}}

推送的任何内容都不会反映在渲染的选择中。

我怀疑您没有使用余烬数组。尝试.pushObject而不是.push

arr = Em.A()
arr.pushObject()

“使用此类中的方法修改数组非常重要,以便可以观察到更改。这允许Ember中的绑定系统正常工作。”

我怀疑您没有使用Ember数组。尝试.pushObject而不是.push

arr = Em.A()
arr.pushObject()

“使用此类中的方法修改数组以使更改可见非常重要。这允许Ember中的绑定系统正常工作。”

感谢这一点,但这不是sort:sort:function(){let arr=this.get(“items”);arr=arr.sort();this.set(“items”,arr);}项目在模板中保持相同的顺序,但数组已更改保存了我的一天。使用ember定义的函数是成功的关键,但这不是sort:sort:function(){let arr=this.get(“items”);arr=arr.sort();this.set(“items”,arr);}这些项在模板中保持相同的顺序,但数组已更改保存日期。使用余烬定义的函数是关键