Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在sencha中使用sessionStorage?_Javascript_Extjs_Session Storage - Fatal编程技术网

Javascript 如何在sencha中使用sessionStorage?

Javascript 如何在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

我正试图让它,一旦用户登录,他们点击刷新,他们将留在同一页。但是现在,当用户登录并单击“刷新”时,会将其发送回登录屏幕。我知道在浏览器未关闭时使用会话存储,这正是我所需要的。但我似乎无法让它正常工作

模型

贮藏

app.js

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();

           }
        });
     },