Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/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
Extjs MemoryProxy me.model是未定义的错误_Extjs_Proxy_Extjs4_Store_Extjs4.1 - Fatal编程技术网

Extjs MemoryProxy me.model是未定义的错误

Extjs MemoryProxy me.model是未定义的错误,extjs,proxy,extjs4,store,extjs4.1,Extjs,Proxy,Extjs4,Store,Extjs4.1,我在内存代理中使用静态数据时遇到了如下错误。 有人能告诉我我的错误或丢失的部分吗 提前谢谢 me.model is undefined me.setProxy(me.proxy || me.model.getProxy()); 我的模型定义: Ext.define(appName + '.model.Country', { extend: 'Ext.data.Model', fields: [ {type: 'string', name: 'abbr'},

我在内存代理中使用静态数据时遇到了如下错误。 有人能告诉我我的错误或丢失的部分吗

提前谢谢

me.model is undefined
me.setProxy(me.proxy || me.model.getProxy());
我的模型定义:

Ext.define(appName + '.model.Country', {    extend: 'Ext.data.Model',
    fields: [
        {type: 'string', name: 'abbr'},
        {type: 'string', name: 'name'},
        {type: 'string', name: 'slogan'}
    ]
});
// The data for all states
var data = {
    states : [
        {'abbr':'AL','name':'Alabama','slogan':'The Heart of Dixie'},
        {'abbr':'AK','name':'Alaska','slogan':'The Land of the Midnight Sun'}
    ]
};


Ext.define(appName + '.store.Countries', {
    extend        : 'Ext.data.Store',
    model        : appName + '.model.Country',
    data        : data,
    proxy: {
        type: 'memory',
        reader: {
            type: 'json',
            root: 'states'
        }
    }
});
Ext.application({
    name: 'APP',
    appFolder: 'application',

    controllers: [
    ...
    ],
    requires: ['APP.model.examples', 'APP.model.other' ...],
    ...
});
以下是我对店铺的定义:

Ext.define(appName + '.model.Country', {    extend: 'Ext.data.Model',
    fields: [
        {type: 'string', name: 'abbr'},
        {type: 'string', name: 'name'},
        {type: 'string', name: 'slogan'}
    ]
});
// The data for all states
var data = {
    states : [
        {'abbr':'AL','name':'Alabama','slogan':'The Heart of Dixie'},
        {'abbr':'AK','name':'Alaska','slogan':'The Land of the Midnight Sun'}
    ]
};


Ext.define(appName + '.store.Countries', {
    extend        : 'Ext.data.Store',
    model        : appName + '.model.Country',
    data        : data,
    proxy: {
        type: 'memory',
        reader: {
            type: 'json',
            root: 'states'
        }
    }
});
Ext.application({
    name: 'APP',
    appFolder: 'application',

    controllers: [
    ...
    ],
    requires: ['APP.model.examples', 'APP.model.other' ...],
    ...
});

您是否尝试显式创建存储并在容器的配置中指定它

例如:

var store = Ext.create(appName + '.store.Countries');
Ext.create('Your Component', {
    ...
    store: store,
    ...
});

您可能需要检查模型文件是否已实际加载并可供使用。在处理大量文件时,ExtJS(我在使用4.2.1时遇到过这种情况)在排序方面存在问题

快速修复方法是在应用程序定义中使用requires:

Ext.define(appName + '.model.Country', {    extend: 'Ext.data.Model',
    fields: [
        {type: 'string', name: 'abbr'},
        {type: 'string', name: 'name'},
        {type: 'string', name: 'slogan'}
    ]
});
// The data for all states
var data = {
    states : [
        {'abbr':'AL','name':'Alabama','slogan':'The Heart of Dixie'},
        {'abbr':'AK','name':'Alaska','slogan':'The Land of the Midnight Sun'}
    ]
};


Ext.define(appName + '.store.Countries', {
    extend        : 'Ext.data.Store',
    model        : appName + '.model.Country',
    data        : data,
    proxy: {
        type: 'memory',
        reader: {
            type: 'json',
            root: 'states'
        }
    }
});
Ext.application({
    name: 'APP',
    appFolder: 'application',

    controllers: [
    ...
    ],
    requires: ['APP.model.examples', 'APP.model.other' ...],
    ...
});
如果这有帮助的话,我在这里写了关于PHP解决方案的更多内容:


你到底在哪里叫我setProxy?为什么要使用动态类名(appName+)?我使用ExtJS4.1和动态加载,所以控制器调用代理。appName是一个常量变量。在Ajax代理中使用相同的配置是没有错误的。(我有其他使用相同模型的存储)否。调用setProxy的代码在哪里?它在你的控制器里吗?或者在基本的ExtJs存储类中?它在存储类中;基本上完成了自动加载设置:true。在store类中添加一些日志,以查看它是否获取模型字符串以及是否能够正确构造模型。为了避免上述错误,您还可以使用:
requires:[]
。这将节省您识别所有模型并将其加载到应用程序定义中的时间。