我在我的 sencha touch 2.1 应用程序的 app.js
级别编写了一个简单的全局函数。
现在,根据在堆栈和其他来源中找到的线索,我需要做的就是从任何地方调用它
TimeMobile.app.myGlobalFunction(params);
关键是,它不起作用,我收到错误:
Uncaught TypeError: Object [object Object] has no method 'getLocalLoggedUserDetails'
我尝试改为调用 launch()
函数,它正在运行。
这比以前更让我困惑,因为在这一点上这不是语法问题。
我这样调用全局函数:
var LoggedUserDetails = TimeMobile.app.getLoggedUserDetails(true);
我的 app.js 是这样定义的:
Ext.Loader.setConfig({
enabled: true
});
Ext.application({
models: [
'LoginResponse'
],
stores: [
'LoginStore',
'PlannedActivityListStore',
'RemoteUserDetailsStore',
'LocalUserDetailsStore'
],
views: [
'LoginView'
],
name: 'TimeMobile',
controllers: [
'ctlLogin',
'ctlPlannedActivities'
],
launch: function() {
//this.TimeMobile =this;
TimeMobile.app.LoggedUser ='';
TimeMobile.app.LoggedUserPsw ='';
TimeMobile.app.AnagId = 'CTEL';
TimeMobile.app.CurrentDate = new Date().toISOString();
TimeMobile.app.LoggedUserDetails = TimeMobile.model.mdlUserDetails();
Ext.create('TimeMobile.view.LoginView', {fullscreen: true});
},
getLoggedUserDetails: function(enabled) {
if (enabled)
{
//var store= TimeMobile.app.LocalUserDetailsStore();
//return store.getAt(0);
console.log('called');
}
else
{
return null;
}
}
});
当我使用语法 TimeMobile.app.getLoadedUserDetails(true);
调用 getLoadedUserDetails
时,我收到了前面提到的错误。
TimeMobile.getLoadedUserDetails(true);
也不起作用。
有什么建议吗?
最佳答案
Chrome 缓存阻止我的 app.js 在应用程序刷新时下载。
我的错。
要禁用 chrome 缓存,请转到控制台,单击右下角的齿轮图标,然后在“常规”选项卡中找到“禁用缓存”复选框。
P.S. 对于那些没有对问题说任何话就给了-1 的人,玩得开心(在我的个人资料上你可以找到很多问题或答案,在那里你可以玩得更开心) .
关于Javascript - Sencha touch 2.1 - 调用 app.js 级函数返回 "[object Object] has no method ' getLocalLoggedUserDetails'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14810981/