使用uni-app的uni.setStorageSync()和uni.getStorageSync()方法来存储和读取密码
在登录页中添加一个记住密码的u-checkbox选项,并在data里面添加一个rememberPwd的布尔值,在每次点击记住密码change的时候来记录用户的选择 <u-checkbox-group placement="column"><u-checkboxv-model="rememberPwd"@change="rememberChange":checked="rememberPwd"label="记住密码"name="yes"></u-checkbox></u-checkbox-group> data() {return {loginForm: {username: "",password: "",},rememberPwd: false,};},methods: {rememberChange(i) {this.rememberPwd = i;},} 在点击登录按钮执行的事件中,使用uni.setStorageSync()方法将【用户名、密码、记住密码】存储在本地缓存中 // 登录逻辑后if (this.rememberPwd) {uni.setStorageSync("HBremember", this.rememberPwd);uni.setStorageSync("HBusername", this.loginForm.username);uni.setStorageSync("HBpassword", this.loginForm.password);} else {// 销毁缓存中的账号、密码uni.removeStorageSync("HBremember");uni.removeStorageSync("HBusername");uni.removeStorageSync("HBpassword");}// 再进行跳转等动作 在登录页的onLoad事件中,使用uni.getStorageSync()方法检查本地缓存中是否存储了rememberPwd的值,如果存储了,则将它赋值给rememberPwd的属性,再取和赋值用户名和密码 onLoad() {//取出缓存中的账号、密码const HBremember = uni.getStorageSync("HBremember");const HBusername = uni.getStorageSync("HBusername");const HBpassword = uni.getStorageSync("HBpassword");if (HBremember && HBusername && HBpassword) {this.loginForm.username = HBusername;this.loginForm.password = HBpassword;this.rememberPwd = HBremember;}},【uni-app2.0】实现登录页记住密码功能,太平洋女性星座网(uni-app 登录)
cpugpu芯片开发光刻机
技术栈专业化分层
13
文件名:【uni-app2.0】实现登录页记住密码功能,太平洋女性星座网
【uni-app2.0】实现登录页记住密码功能
同类推荐
-

【QGIS入门实战精品教程】4.8:QGIS如何下载SRTM数字高程模型DEM?,jon secada
查看 -

【Qt之布局】QVBoxLayout、QHBoxLayout、QGridLayout、QFormLayout介绍及使用,金立a696手机
查看 -

【Qt开发流程】之打印文档,柯达v570(柯达可以打印文件吗)
查看 -

【RH850芯片】RH850U2A芯片平台Spinlock的底层实现,vidz(rh850芯片手册)
查看 -

【RabbitMQ】 RabbitMQ 消息的延迟 —— 深入探索 RabbitMQ 的死信交换机,消息的 TTL 以及延迟队列,华为t5211
查看 -

【React】classnames 库(可添加多个 className 类名),t11te
查看 -

【React基础二】事件绑定、组件props、条件渲染、列表、refs、组件声明周期,华为ec321
查看 -

【Redis】Redis内存过期策略和内存淘汰策略,REALPLAYER 11
查看 -

【Redis使用】一年多来redis使用笔记md文档,第(2)篇:命令和数据库操作,祥仔j8av
查看
控制面板
网站分类
搜索
最新留言
文章归档
网站收藏
友情链接