gpt4 book ai didi

javascript - extjs4 类型错误 : store is undefined

转载 作者:行者123 更新时间:2023-12-03 11:34:54 25 4
gpt4 key购买 nike

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

enter image description here

Eclipse 中的应用程序结构如上。我遇到的问题是关于商店

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'

提前致谢!

最佳答案

我认为您可以通过在 app.js 配置中为类似 Controller 的商店添加一个条目,将您的商店引用为 'AM.store.Users'

stores:['Users']

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

关于javascript - extjs4 类型错误 : store is undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26559323/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com