vue实现记住密码功能
<a-checkbox @change="onChange" :checked="checked"> 记住密码</a-checkbox>
onChange() {
this.checked = !this.checked
},
loginSuccess( value) {
let val = JSON.stringify(value)
if (this.checked) {
window.localStorage.setItem('rememberInfo', val)
} else {
window.localStorage.removeItem('rememberInfo')
}
}
let obj = JSON.parse(window.localStorage.getItem('rememberInfo'))
if (obj != null) {
if (obj.password && obj.username) {
this.username = obj.username
this.password = obj.password
this.checked = true
}
}