#鸿蒙通关秘籍#如何在HarmonyOS NEXT中实现记住密码和忘记密码功能?

HarmonyOS
2024-11-27 11:20:14
750浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
数据小战士

记住密码功能通过图标点击事件和文本点击事件实现;点击时更新rememberPassword状态,并保存到本地存储。若未选记住密码,密码则会被清空。忘记密码功能通过路由跳转实现。

Row() {
  Image($r(this.rememberPassword ? 'app.media.radio_normal_checkmark' : 'app.media.radio_normal'))
    .onClick(async () => {
      this.rememberPassword = !this.rememberPassword;
      await PreferencesUtils.put("rememberPassword", this.rememberPassword);
      if (!this.rememberPassword) {
        await PreferencesUtils.put("account", '');
        await PreferencesUtils.put("password", '');
      }
    });

  Text('忘记密码')
    .onClick(() => {
      router.pushUrl({ url: 'pages/Forgot' });
    });
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
分享
微博
QQ
微信
回复
2024-11-27 12:10:13


相关问题
HarmonyOS 如何实现手势密码功能
1129浏览 • 1回复 待解决
加密密码键盘的实现
381浏览 • 0回复 待解决