Sencha touch 未捕获类型错误:无法读取属性';iModel';未定义的
嗨,我在执行我的代码后遇到了这个错误。它说“UncaughtTypeError:无法读取undefined的属性'isModel'。我试图使用我定义的名为“model.login”的模型和一个包含伪数据的存储来显示一个列表Sencha touch 未捕获类型错误:无法读取属性';iModel';未定义的,sencha-touch,Sencha Touch,嗨,我在执行我的代码后遇到了这个错误。它说“UncaughtTypeError:无法读取undefined的属性'isModel'。我试图使用我定义的名为“model.login”的模型和一个包含伪数据的存储来显示一个列表 Ext.Loader.setConfig({ enabled: true, paths:{ 'model' : 'app/model', 'store' : 'app/store' } }); Ext.application({ name: 'GS'
Ext.Loader.setConfig({
enabled: true,
paths:{
'model' : 'app/model',
'store' : 'app/store'
}
});
Ext.application({
name: 'GS',
launch: function(){
var myStore = null;
Ext.require('model.login', function(){
var login = Ext.create('model.login');
myStore = new Ext.data.Store({
model: login,
data:[
{id:'09803' , issued_at: 'thisurl', instance_url:'https', signature:'token', access_token:'ser'}
]
});
});
this.viewport = new Ext.Panel({
fullscreen: true,
items:[
{
xtype: 'list',
itemTpl: '{id}',
store: myStore
}
]
});
}
});
您对创建视口的调用发生在
模型之前。已加载登录名并创建存储。将创建视口的代码移动到Ext.require
的回调中
此外,将模型传递到存储时,传递的是模型构造函数,而不是它的实例
Ext.application({
name: 'GS',
launch: function(){
this.viewport =
var me = this;
Ext.require('model.login', function(){
myStore = new Ext.data.Store({;
me.viewport = new Ext.Panel({
fullscreen: true,
// You can pass a single item into item
items:{
xtype: 'list',
itemTpl: '{id}',
store: myStore
}
});
});
}
});
请注意,有一种更好的方法可以做到这一点,您可以告诉应用程序要加载哪些模型,并内联一些调用以使其更易于阅读
Ext.application({
name: 'GS',
models: 'login', // looks in GS.model.login
launch: function(){
me.viewport = new Ext.Panel({
fullscreen: true,
// You can pass a single item into item
items:{
xtype: 'list',
itemTpl: '{id}',
store: {
model: 'model.login', // or GS.model.login without quotes
data:[
{id:'09803' , issued_at: 'thisurl', instance_url:'https', signature:'token', access_token:'ser'}]
}
}
});
}
});
我按照您的建议移动了代码,但仍然出现相同的错误,Uncaught TypeError:无法读取undefined的属性'isModel'。感谢您,这似乎使错误消失,但页面现在是空白的。@KevinMorfin每篇文章只需问一个问题,这使文章对其他阅读该网站的人尽可能有用。你应该为新问题问一个新问题。所问的问题已经得到了回答,对其他可能有同样问题的人来说已经很有帮助了