您现在的位置是:首页 > 前端会客厅 > 前端框架前端框架

vue 登录模块记住密码功能模块

YU到边2022-04-07【前端框架】人已围观

简介没啥好说的的直接上代码



 

mounted() {
  let buer = window.localStorage.getItem('checked');
      buer === 'true' ? this.checked = true : this.checked = false;
     if (this.checked) {
     let form = JSON.parse(window.localStorage.getItem('form'));
     this.form = form;
     }
}

login() {
  let _this = this;
  this.$refs.form.validate(async valid => {
    if (!valid) return false
    this.loading = true
    try {
      window.localStorage.setItem('checked', this.checked);
      if (this.checked) {
        let data = JSON.parse(JSON.stringify(_this.form));
        window.localStorage.setItem('form', JSON.stringify(data));
      }
      await this.$store.dispatch('login', this.form);
    } catch (error) {
    }
    this.loading = false
  })
},

Tags:vue   记住密码

很赞哦! ()

文章评论