基于vue 實(shí)現(xiàn)表單中password輸入的顯示與隱藏功能
實(shí)現(xiàn)效果:
點(diǎn)擊 “眼睛” 的時(shí)候顯示與隱藏
代碼:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link href="css/bootstrap.min.css" rel="external nofollow" rel="stylesheet"> <script src="js/vue.js"></script> <title>Title</title> <style> #main{ text-align: center; margin-top:60px; } input[type=text],input[type=password]{ width:260px; height:28px; display: inline-block; } span{ margin-left:-30px; cursor: pointer; } input[type=checkbox]{ cursor: pointer; opacity: 0; margin-left:-18px; display: inline-block; } </style> </head> <body> <div id="main"> <input type="text" class="form-control" v-model="msg" v-if="checked"> <input type="password" class="form-control" v-model="msg" v-else> <span class="glyphicon glyphicon-eye-open"></span> <input type="checkbox" v-model="checked"> </div> <script> new Vue({ el:"#main", data:{ msg:"", checked:false }, methods:{ } }); </script> <script src="js/jquery.min.js"></script> <script src="js/bootstrap.min.js"></script> </body> </html>
=====================================
登錄頁(yè)面input輸入密碼顯示與隱藏實(shí)現(xiàn):
效果(點(diǎn)擊顯示與隱藏進(jìn)行切換):
代碼:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title></title> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <script src="js/vue.js"></script> <script src="js/vue-resource.js"></script> <style> body{ background:white; } .main{ padding-top:50px;width:95%;margin:0 auto; } .account{ border-bottom:1px solid #dfdfdf;padding-top:28px; } .account input{ border:none;font-size:14px;margin-bottom:5px;width:91.5%;height:44px; } .account i{ width:14px; height:14px; line-height:14px; font-size:18px; display:inline-block; color:white; background:#cdcdcd; border-radius:50%; text-align:center; font-style:normal; } .account .psd{ width:81.6%; } .account span{ color:#bfbfbf;float:right;line-height:40px; } </style> </head> <body> <div id="login"> <div class="main"> <div class="account"> <input type="password" placeholder="密碼" class="psd" v-model="psd" v-if="ifDisplay"/> <input type="text" placeholder="密碼" class="psd" v-model="psd" v-else/> <i v-show="psd" @click="clearPassword()">×</i> <span v-show="ifDisplay" @click="ifDisplay=!ifDisplay">隱藏</span> <span v-show="!ifDisplay" @click="ifDisplay=!ifDisplay">顯示</span> </div> </div> </div> <script type="text/javascript"> var vm=new Vue({ el:'#login', data:{ username:'', psd:'', ifDisplay:false, }, methods:{ clearPassword:function(){ this.psd=''; }, } }) </script> </body> </html>
總結(jié)
以上所述是小編給大家介紹的基于vue 實(shí)現(xiàn)表單中password輸入的顯示與隱藏功能,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺(jué)得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
相關(guān)文章
一起寫一個(gè)即插即用的Vue Loading插件實(shí)現(xiàn)
這篇文章主要介紹了一起寫一個(gè)即插即用的Vue Loading插件實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10在vue中路由使用this.$router.go(-1)返回兩次問(wèn)題
這篇文章主要介紹了在vue中路由使用this.$router.go(-1)返回兩次問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-12-12在Vue中進(jìn)行數(shù)據(jù)分頁(yè)的實(shí)現(xiàn)方法
在前端開發(fā)中,數(shù)據(jù)分頁(yè)是一個(gè)常見(jiàn)的需求,特別是當(dāng)處理大量數(shù)據(jù)時(shí),Vue作為一款流行的JavaScript框架,提供了強(qiáng)大的工具和生態(tài)系統(tǒng)來(lái)實(shí)現(xiàn)數(shù)據(jù)分頁(yè),本文將介紹如何在Vue中進(jìn)行數(shù)據(jù)分頁(yè),以及如何設(shè)計(jì)一個(gè)通用的分頁(yè)組件,需要的朋友可以參考下2023-10-10vue中計(jì)算屬性computed和普通屬性method的區(qū)別小結(jié)
Vue.js中Computed和Methods是兩種常用的數(shù)據(jù)處理方式,本文主要介紹了vue中計(jì)算屬性computed和普通屬性method的區(qū)別小結(jié),具有一定的參考價(jià)值,感興趣的可以了解一下2024-06-06