mui 使用LocalStore记住用户密码方法
生活随笔
收集整理的這篇文章主要介紹了
mui 使用LocalStore记住用户密码方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
mui框架開發的APP 的本地緩存里記錄密碼<!DOCTYPE html>
<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /><title></title><script src="js/mui.min.js"></script><link href="css/mui.min.css" rel="stylesheet" /><script type="text/javascript" charset="utf-8">mui.init();</script><style>body {margin-left: 500px;}fieldset {width: 380px;height: 220px;text-align: center;}#txtId,#txtPwd {width: 240px;margin: 10px auto;}</style></head><body><fieldset id=""><legend>用戶登錄</legend>用戶名:<input type="text" id="txtId" /><br /> 密碼:<input type="password" id="txtPwd" /><br /><input type="checkbox" id="chkRem" />記住密碼<br /><input type="button" value="登錄" onclick="remPwd()" /></fieldset><script type="text/javascript">var Id = localStorage.getItem("txtId");if(Id != null) //如果緩存中有數據,則加載出來 {document.getElementById("txtId").value = Id;document.getElementById("txtPwd").value = localStorage.getItem("txtPwd");document.getElementById("chkRem").checked = "checked";}//將賬號與密碼保存到Localstore function remPwd() {var check = document.getElementById("chkRem");if(check.checked) //判斷記住密碼項是否勾選,是則記住密碼到本地緩存 {var id = document.getElementById("txtId").value;var pwd = document.getElementById("txtPwd").value;localStorage.setItem("txtId", id);localStorage.setItem("txtPwd", pwd);} else //否則就移除本地緩存 {localStorage.removeItem("txtId");localStorage.removeItem("txtPwd");}}</script></body></html>
?
總結
以上是生活随笔為你收集整理的mui 使用LocalStore记住用户密码方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ftp服务用户访问权限设置
- 下一篇: 如何通过 macOS 恢复功能重新安装