简体   繁体   中英

extjs4 TypeError: store is undefined

I am a newbie for extjs4. I am reading the application architecture in the extjs offical website which offered a simple example( application_architecture ). But I encountered some issues when studying this case.

在此处输入图片说明

The app sturcture in eclipse is like above. The question I met is regarding the store .

app\\controller\\Users.js please look at the comment in this piece of code.

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'
    ],

Now I pasted the code of the other files related to this issue.

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'
        }
    }
});

I have searched for the exception in google, but got nothing helpful, and I have debugged it in firefox, still nothing, maybe because I am an expert in javascript. I also checked the source code of other extjs apps in the company I worked, I found the controller can refer to the store like 'AM.store.Users'

Thanks in advance!

I think you can refer your store as 'AM.store.Users' by adding an entry in your app.js config for stores like below similar to controllers.

stores:['Users']

Please try it once,hope it will help you.

app.js 不应该用重要的逻辑修改,因为它会在每次框架更新时重写

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM