Javascript 如何在sencha中使用sessionStorage?
我正试图让它,一旦用户登录,他们点击刷新,他们将留在同一页。但是现在,当用户登录并单击“刷新”时,会将其发送回登录屏幕。我知道在浏览器未关闭时使用会话存储,这正是我所需要的。但我似乎无法让它正常工作 模型 贮藏 app.jsJavascript 如何在sencha中使用sessionStorage?,javascript,extjs,session-storage,Javascript,Extjs,Session Storage,我正试图让它,一旦用户登录,他们点击刷新,他们将留在同一页。但是现在,当用户登录并单击“刷新”时,会将其发送回登录屏幕。我知道在浏览器未关闭时使用会话存储,这正是我所需要的。但我似乎无法让它正常工作 模型 贮藏 app.js launch: function() { // Destroy the #appLoadingIndicator element Ext.fly('appLoadingIndicator').destroy(); var session=Ext.ge
launch: function() {
// Destroy the #appLoadingIndicator element
Ext.fly('appLoadingIndicator').destroy();
var session=Ext.getStore('Login');
session.load();
var record = session.getAt('userName');
alert(record);
if(record != undefined){
//exits to main menus not login
}
else
Ext.Viewport.add(Ext.create('MeterReadingsApp.view.Login'));
},
控制器
loginButton: function(){
// var me = this;
Ext.Ajax.request({
useDefaultXhrHeader:false,
url: getLogonUrl(),
method: 'POST',
headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
params : {
"userName": Ext.getCmp('username').getValue(),
"password": Ext.getCmp('password').getValue()
},
success: function (response) {
Ext.getCmp('failLogin').hide(),
Ext.getStore('Login').sync();
Ext.Viewport.setActiveItem({xtype: 'Main'});
Ext.getStore('Campuses').load();
},
failure: function(response) {
Ext.getCmp('loginform').doSetHeight(250),
Ext.getCmp('failLogin').show();
}
});
},
谢谢你的帮助 您需要在存储上设置storeId属性。您正在尝试使用代理的id获取存储
launch: function() {
// Destroy the #appLoadingIndicator element
Ext.fly('appLoadingIndicator').destroy();
var session=Ext.getStore('Login');
session.load();
var record = session.getAt('userName');
alert(record);
if(record != undefined){
//exits to main menus not login
}
else
Ext.Viewport.add(Ext.create('MeterReadingsApp.view.Login'));
},
loginButton: function(){
// var me = this;
Ext.Ajax.request({
useDefaultXhrHeader:false,
url: getLogonUrl(),
method: 'POST',
headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
params : {
"userName": Ext.getCmp('username').getValue(),
"password": Ext.getCmp('password').getValue()
},
success: function (response) {
Ext.getCmp('failLogin').hide(),
Ext.getStore('Login').sync();
Ext.Viewport.setActiveItem({xtype: 'Main'});
Ext.getStore('Campuses').load();
},
failure: function(response) {
Ext.getCmp('loginform').doSetHeight(250),
Ext.getCmp('failLogin').show();
}
});
},