Sencha touch 2 Sencha触控激活项
对于Sencha来说,我有一个登录表单,它运行良好,并通过ajax发布所需的表单元素。成功后,它将数据存储在localStorage.token中,然后移动到下一页。我想要的是,当应用程序加载时,如果localStorage.token中已经有数据,那么它会直接进入第二页。我尝试了setActiveItem,但没有达到预期的效果 这是我的app.js:Sencha touch 2 Sencha触控激活项,sencha-touch-2,Sencha Touch 2,对于Sencha来说,我有一个登录表单,它运行良好,并通过ajax发布所需的表单元素。成功后,它将数据存储在localStorage.token中,然后移动到下一页。我想要的是,当应用程序加载时,如果localStorage.token中已经有数据,那么它会直接进入第二页。我尝试了setActiveItem,但没有达到预期的效果 这是我的app.js: //<debug> Ext.Loader.setPath({ 'Ext': 'touch/src' }); //&l
//<debug>
Ext.Loader.setPath({
'Ext': 'touch/src'
});
//</debug>
Ext.application({
name: 'axis3',
//profiles: ['Phone', 'Tablet', 'Desktop'],
requires: [
'Ext.MessageBox'
],
views: ['Login','Main'],
controllers:['Login','Main'],
icon: {
'57': 'resources/icons/Icon.png',
'72': 'resources/icons/Icon~ipad.png',
'114': 'resources/icons/Icon@2x.png',
'144': 'resources/icons/Icon~ipad@2x.png'
},
isIconPrecomposed: true,
startupImage: {
'320x460': 'resources/startup/320x460.jpg',
'640x920': 'resources/startup/640x920.png',
'768x1004': 'resources/startup/768x1004.png',
'748x1024': 'resources/startup/748x1024.png',
'1536x2008': 'resources/startup/1536x2008.png',
'1496x2048': 'resources/startup/1496x2048.png'
},
launch: function() {
// Destroy the #appLoadingIndicator element
Ext.fly('appLoadingIndicator').destroy();
// Initialize the login view
Ext.Viewport.add([
{ xtype: 'loginview' },
{ xtype: 'mainview' }
]);
Ext.Ajax.setUseDefaultXhrHeader(false);// needed to enable cross domain request.
},
onUpdated: function() {
Ext.Msg.confirm(
"Application Update",
"This application has just successfully been updated to the latest version. Reload now?",
function(buttonId) {
if (buttonId === 'yes') {
window.location.reload();
}
}
);
}
});
//
Ext.Loader.setPath({
“Ext”:“touch/src”
});
//
外部应用程序({
名称:“axis3”,
//个人资料:[“手机”、“平板电脑”、“桌面”],
要求:[
“Ext.MessageBox”
],
视图:['Login','Main'],
控制器:['Login','Main'],
图标:{
“57”:“resources/icons/Icon.png”,
'72':'resources/icons/Icon~ipad.png',
“114”:“资源/图标”/Icon@2x.png',
“144”:“资源/图标/图标”~ipad@2x.png'
},
isIconPrecomposed:正确,
startupImage:{
“320x460”:“resources/startup/320x460.jpg”,
“640x920”:“resources/startup/640x920.png”,
“768x1004”:“resources/startup/768x1004.png”,
“748x1024”:“resources/startup/748x1024.png”,
“1536x2008”:“resources/startup/1536x2008.png”,
'1496x2048':'resources/startup/1496x2048.png'
},
启动:函数(){
//销毁#appLoadingIndicator元素
Ext.fly('appLoadingIndicator').destroy();
//初始化登录视图
Ext.Viewport.add([
{xtype:'loginview'},
{xtype:'mainview'}
]);
Ext.Ajax.setUseDefaultXhrHeader(false);//需要启用跨域请求。
},
未更新:函数(){
Ext.Msg.confirm(
“应用程序更新”,
“此应用程序刚刚成功更新为最新版本。是否立即重新加载?”,
功能(按钮){
如果(buttonId==“是”){
window.location.reload();
}
}
);
}
});
感谢您的帮助我将根据您的令牌检查结果添加您需要的一个视图:
launch: function() {
// Destroy the #appLoadingIndicator element
Ext.fly('appLoadingIndicator').destroy();
var hasToken = this.hasToken();
if (hasToken)
Ext.Viewport.setActiveItem({ xtype: 'mainview' });
else
Ext.Viewport.setActiveItem({ xtype: 'loginview' });
Ext.Ajax.setUseDefaultXhrHeader(false);// needed to enable cross domain request.
},
我只想根据您的令牌检查结果添加您需要的一个视图:
launch: function() {
// Destroy the #appLoadingIndicator element
Ext.fly('appLoadingIndicator').destroy();
var hasToken = this.hasToken();
if (hasToken)
Ext.Viewport.setActiveItem({ xtype: 'mainview' });
else
Ext.Viewport.setActiveItem({ xtype: 'loginview' });
Ext.Ajax.setUseDefaultXhrHeader(false);// needed to enable cross domain request.
},