Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.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 余烬数据:findRecord未定义。(也可以是peekRecord或peekAll)_Javascript_Ember.js_Ember Data - Fatal编程技术网

Javascript 余烬数据:findRecord未定义。(也可以是peekRecord或peekAll)

Javascript 余烬数据:findRecord未定义。(也可以是peekRecord或peekAll),javascript,ember.js,ember-data,Javascript,Ember.js,Ember Data,我正在尝试切换到余烬数据,但似乎无法找到此错误的解决方案: TypeError:this.store.findRecord不是函数。(在'this.store.findRecord'feed',feed_id'中,'this.store.findRecord'未定义) 这是我在控制器中作为操作的代码: toggleArchive(feed_id, param,intercom_event){ var self = this; this.set('isLoa

我正在尝试切换到余烬数据,但似乎无法找到此错误的解决方案:

TypeError:this.store.findRecord不是函数。(在'this.store.findRecord'feed',feed_id'中,'this.store.findRecord'未定义)

这是我在控制器中作为操作的代码:

    toggleArchive(feed_id, param,intercom_event){
        var self = this;
        this.set('isLoading',true);

        return this.store.findRecord('feed', feed_id).then(function(feed) {
            //Setting the system_status of the feed to either 4 (archived) or 1 (normal)
            feed.set('system_status',param);
            //Persist to change to store (and server)
            return feed.save();
        });
    },
在我所说的路线上:

model: function(params){
    return this.store.findRecord('feed',params.feed_id);
},
并在package.json im中使用:“余烬数据”:“1.13.8”

如果我调用旧的
this.store.find()
方法,则会检索记录,但这并不理想,因为该方法已被弃用,而且我的工作方式也不符合预期

有没有关于我可能做错了什么的提示


谢谢:)

您还需要bower.json中的余烬数据包条目:

"ember-data": "1.13.8"

哪里是
toggleArchive
?在
toggleArchive
内部调用
this.store.XXX
无效。您需要在该函数之外重新定义
var self=this
,以避免隐藏它。奇怪的是,find()方法工作得非常好。但我需要findRecord才能工作。toggleArchive在控制器中的一个动作中。