Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/399.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 找不到ExtJS Store reader.read_Javascript_Extjs_Jsonp_Extjs4.1 - Fatal编程技术网

Javascript 找不到ExtJS Store reader.read

Javascript 找不到ExtJS Store reader.read,javascript,extjs,jsonp,extjs4.1,Javascript,Extjs,Jsonp,Extjs4.1,我有这家店: Ext.define("App.store.units.MyStore", { extend:'Ext.data.Store', requires: "App.model.units.MyModel", model: "App.model.units.MyModel", id:'myStore', pageSize:10, proxy: { type: 'jsonp', url: urls.MyUr

我有这家店:

Ext.define("App.store.units.MyStore", {

    extend:'Ext.data.Store',
    requires: "App.model.units.MyModel",

    model: "App.model.units.MyModel",
    id:'myStore',
    pageSize:10,
    proxy: {
        type: 'jsonp',
        url: urls.MyUrl+"/search",
        limitParam: 'undefined',
        startParam: 'offSet',
        pageParam: 'undefined',
        extraParams: {
            searchString: 'a'
        },
        reader: {
            root: 'results.results',
            totalProperty: 'numFound',
            type: 'json'
        }
    }
});
请求有效,我得到了预期的响应

出于某种原因,现在我在浏览器中看到:

reader.read is not a function
我不明白问题出在哪里,因为昨天一切正常(我知道这听起来如何,但我真的不知道有什么不同)

有什么建议可能有用吗

编辑以下是模型的(动态)定义:

function(config){
    try{
        console.log("INIT MODEL");
    Ext.define("App.model.units.MyModel", {
        extend: 'Ext.data.Model',
        fields: config
    });
    } catch(err){
        console.log("Error");
    }
}
此函数在创建存储之前运行,
config
对象是
{name:'value'}
项的
数组

我不知道怎么了。现在Firefox中的一切似乎都运行良好,但IE8仍然存在该错误(阅读器中的事件类型为
type:'json'
)。我认为阅读器在IE8中没有正确安装,但我无法检查它,因为对象没有正确显示在它的控制台中(或者我不知道怎么做)。为什么相同的javascript代码不能正常运行


以后编辑出于某种原因,我只能偶尔创建
阅读器。这就是问题所在。有时它只是一个对象,而不是所需的
读取器
。这在Firefox中也会发生。似乎没有任何模式。

我也有类似的问题。这有助于:

Ext.require('App.model.units.MyModel');
//or any other model you use in your store

在你创建商店之前,把它放在某个地方,它就可以工作了

requires配置是一个数组,如ExtJS文档中所述:


我在删除存储字段时出现此错误。我有这个给grid

网格

            columns: [
                {header: "Status", width: 75, sortable: true, dataIndex: 'partystatus'},
                {header: "Name", width: 160, sortable: true, dataIndex: 'partyname'},
                {header: "Fathersname", width: 75, sortable: true, dataIndex: 'fathersname'},
                {header: "Grandfather", width: 75, sortable: true, dataIndex: 'grandfather'},
                {header: "Type", width: 75, sortable: true, dataIndex: 'partytype'}
            ],
以下是商店的信息:

商店

    fields: [
        {name: 'firstName', type: 'string'},
        {name: 'name', type: 'string'},
        {name: 'age', type: 'int'},
        {name: 'eyeColor', type: 'string'}
    ],

我只是简单地删除了存储字段,认为它们是多余的,但我得到了那个错误。

在我看来,这似乎是一个与模型相关的问题。尝试用一个简单的
字段:[……]
声明替换
模型:
引用,然后查看存储是否成功加载。另外,请将您的代码发布到App.model.units.MyModel
@VasiliyFaronov,这与模型无关。模型是动态定义的,接收的字段在模型中定义的字段中。对此我绝对有把握。在我刷新了几次
并更改了一些
console.log()
之后,Firefox中的一切似乎都很好(但我仍然不知道为什么)。IE8仍然显示类似的错误。还有其他建议吗?我只是想问一下,因为我已经在JSFIDLE中尝试了你的代码,它给了我同样的错误,直到我在
字段中声明了
。从我自己的经历中,我隐约记得类似的事情。问题可能不在于模型本身,而在于读者与模型的连接方式。除此之外,试着在加载之前打开你商店的
并手动检查
商店.getProxy().getReader()
,看看有没有什么有趣的地方。也试着直接在你的阅读器上设置
模型
,以防万一。错售<代码>需要
而不是
需要