Ember : addObject/ pushObject is not a function

扶醉桌前 提交于 2019-12-08 13:18:50

问题


I recently moved from ember 1.x to 2.6. I am not able to use addObject/pushObject like i used to.

Ember      : 2.6.2
jQuery     : 2.2.4

import Ember from 'ember';

export default Ember.Controller.extend({
    test: ['sibi', 'john'],

    init: function() {
        this.get('test').pushObject('sebastian');
    }
});

This throws an error like pushObject is not a function. What is the workaround? Thank you.


回答1:


The extend prototypes option was false for some reason. You can read more about disabling prototype extensions in the guide.

EmberENV: {
      EXTEND_PROTOTYPES: {
        Array: true
      }
    }

Thank you!




回答2:


Check your package.json against ember-disable-prototype-extensions.

If your project is an addon project it had beed added by ember-cli. And you should live with it. (Use Ember.A whenever you need an Ember array.)

If your project is an application project, just remove this addon.



来源:https://stackoverflow.com/questions/38714527/ember-addobject-pushobject-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!