extjs4 TypeError:存储区未定义

问题描述 投票:0回答:2

我是extjs4的新手。我正在extjs官方网站上阅读应用程序架构,该网站提供了一个简单的示例(application_architecture)。但是在研究此案时,我遇到了一些问题。

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9XVzc0dy5wbmcifQ==” alt =“在此处输入图像描述”>

eclipse中的应用程序结构如上。我遇到的问题与store

有关

app \ controller \ Users.js请看这段代码中的注释。

Ext.define('AM.controller.Users', {
    extend: 'Ext.app.Controller',
    stores: [
        'AM.store.Users'  //this line of code can't work, unless I update it to `Users`
                          //or it will report the exception 'TypeError: store is undefined'
    ],
    models: [
        'AM.model.User'
    ],

现在我粘贴了与此问题相关的其他文件的代码。

app \ store \ Users.js

Ext.define('AM.store.Users', {
    extend: 'Ext.data.Store',
    model: 'AM.model.User',
    autoLoad: true,

    proxy: {
        type: 'ajax',
        api: {
            read: 'data/users.json',
            update: 'data/updateUsers.json'
        },
        reader: {
            type: 'json',
            root: 'users',
            successProperty: 'success'
        }
    }
});

我已经在google中搜索了该异常,但是没有任何帮助,并且我已经在firefox中对其进行了调试,但仍然没有任何效果,也许是因为我是javascript方面的专家。我还检查了我工作的公司中其他extjs应用程序的源代码,发现controller可以引用store,例如'AM.store.Users'

提前感谢!

javascript extjs extjs4 extjs4.2
2个回答
1
投票

我认为您可以通过在app.js配置中为类似于控制器的以下商店添加条目来将您的商店称为'AM.store.Users'

stores:['Users']

请尝试一次,希望对您有帮助。


0
投票

app.js不应使用重大逻辑进行修改,因为它将在每次框架更新时进行重写

© www.soinside.com 2019 - 2024. All rights reserved.