Javascript ExtJS 5.1在本地商店记得我吗

Javascript ExtJS 5.1在本地商店记得我吗,javascript,extjs,Javascript,Extjs,我试着用一个有趣的算法来记住我。我在想,当我点击RememberMe并登录时,文本字段(用户名和密码)的值将保存为默认值。我的登录按钮单击此处的事件: var username = Ext.getCmp('setNo').getValue(); var password= Ext.getCmp('setPass').getValue(); if(refs.checkStudent.value === true){ Ext.getCmp('setNo').

我试着用一个有趣的算法来记住我。我在想,当我点击RememberMe并登录时,文本字段(用户名和密码)的值将保存为默认值。我的登录按钮单击此处的事件:

    var username = Ext.getCmp('setNo').getValue();
    var password= Ext.getCmp('setPass').getValue();

    if(refs.checkStudent.value === true){
        Ext.getCmp('setNo').setValue(username);
        Ext.getCmp('setPass').setValue(password);
    }
    else{
        Ext.getCmp('setNo').setValue("");
        Ext.getCmp('setParola').setValue("");
    }

在控制台上,它正在工作。但我在一家本地商店工作,没有服务器。所以当我刷新页面时,它就消失了。有没有办法不丢失它们?

在您的视图上
onAfterRender
事件:

Use ExtJs utility to set and get values in cookies. At time of login set 
username and password in cookies and after refresh the page read username
and password value from the cookie. 

Ext.util.Cookies.set('username', username); // To set value in cookie.
Ext.util.Cookies.get('username'); // to get value form cookie.
Ext.getCmp('setNo').setValue(localStorage.username);
Ext.getCmp('setPass').setValue(localStorage.password);
在按钮上单击事件:

if (refs.checkStudent.value === true) {
    localStorage.username = Ext.getCmp('setNo').getValue();
    localStorage.password = Ext.getCmp('setPass').getValue();
} else {
    localStorage.removeItem('username');
    localStorage.removeItem('password');
}

您还可以使用本地存储来完成这项工作。