[英]extjs4 TypeError: store is undefined
I am a newbie for extjs4.我是 extjs4 的新手。 I am reading the application architecture in the extjs offical website which offered a simple example( application_architecture ).我正在阅读 extjs 官方网站中的应用程序架构,它提供了一个简单的示例( application_architecture )。 But I encountered some issues when studying this case.但是我在研究这个案例时遇到了一些问题。
The app sturcture in eclipse is like above. eclipse 中的应用程序结构如上所示。 The question I met is regarding the store .我遇到的问题是关于商店的。
app\\controller\\Users.js please look at the comment in this piece of code. 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'
],
Now I pasted the code of the other files related to this issue.现在我粘贴了与此问题相关的其他文件的代码。
app\\store\\Users.js应用\\商店\\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.我在 google 中搜索过异常,但没有任何帮助,我在 Firefox 中对其进行了调试,仍然没有,可能是因为我是 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'我还检查了我工作的公司中其他 extjs 应用程序的源代码,我发现控制器可以引用像“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.我认为您可以通过在 app.js 配置中为类似于控制器的商店添加一个条目来将您的商店称为'AM.store.Users'
。
stores:['Users']
Please try it once,hope it will help you.请尝试一次,希望对您有所帮助。
app.js 不应该用重要的逻辑修改,因为它会在每次框架更新时重写
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.