1、HTML
<el-checkbox v-model="checked" style="color: #ffffff">记住账号</el-checkbox
2、定义
data() {
return {
userName: "",
passWord: "",
checked: false,
loginLoading: false,
};
},
3、一般是利用LocalStorage进行储存
const accessInfo = {
remember: this.checked,
userName: this.userName
};
if (this.checked)
setLocalStorage("accessInfo", JSON.stringify(accessInfo));
this.login(userName, password);
4、取
mounted() {
let accessInfo = getLocalStorage("accessInfo");
console.log(accessInfo);
if (accessInfo) {
const data = JSON.parse(accessInfo);
this.checked = data.remember;
this.userName = data.userName;
}
},