problem description
users need to save the information of the last login and use localstorage to record the contents of the input box, including the password, after the login is successful.
is not a complete phenomenon . Sometimes the Android phone Wechat browser localstorage is inexplicably cleared, and the whole project does not write the code to remove localstorage. Only Android phones appear, not Apple.
the environmental background of the problems and what methods you have tried
to prevent the localstorage from being cleared and causing the user to type again, I even used cookie, but the weird thing is that cookie was cleared along with localstorage.
related codes
the project uses the vue framework, not other ui frameworks.
mounted() {
//
let username = localStorage.getItem("username") || this.getCookie("username");
let password = localStorage.getItem("password") || this.getCookie("password");
if (username) {
this.user.username = username;
}
if (password) {
this.user.password = password;
}
},
//
localStorage.setItem("username", this.user.username);
localStorage.setItem("password", this.user.password);
this.setCookie("username",this.user.username)
this.setCookie("password",this.user.password)