使用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芯片开发光刻机
技术栈专业化分层
10
文件名:【uni-app2.0】实现登录页记住密码功能,太平洋女性星座网
【uni-app2.0】实现登录页记住密码功能
同类推荐
-

【QGIS入门实战精品教程】4.6:QGIS实现栅格(影像、DEM)的拼接与掩膜提取,联想y460报价
查看 -

【Qt学习】04:QDialog,htc t328d desire vc
查看 -

【Qt开发流程】之HelloWorld程序,高清片源(qt helloworld程序)
查看 -

【ROS】RViz2源码下载、编译、运行(ros2源码安装)
查看 -

【ROS】参数服务器--理论模型与参数操作(C++),t11te(ros动态参数服务器)
查看 -

【ROS系统】Ubuntu22.04系统中安装ROS2系统_ubuntu 安装ros2_GoesM,酷派8310
查看 -

【RWKV】如何新增一个自定义的Tokenizer和模型到HuggingFace,lumia800c
查看 -

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

【RabbitMQ】RabbitMQ详解(二),推荐几个安全没封的网站2021
查看