這篇文章將為大家詳細(xì)講解有關(guān)vue如何實(shí)現(xiàn)表單中password輸入的顯示與隱藏功能,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

實(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>=====================================
登錄頁面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>Vue具體輕量級(jí)框架、簡單易學(xué)、雙向數(shù)據(jù)綁定、組件化、數(shù)據(jù)和結(jié)構(gòu)的分離、虛擬DOM、運(yùn)行速度快等優(yōu)勢,Vue中頁面使用的是局部刷新,不用每次跳轉(zhuǎn)頁面都要請求所有數(shù)據(jù)和dom,可以大大提升訪問速度和用戶體驗(yàn)。
關(guān)于“vue如何實(shí)現(xiàn)表單中password輸入的顯示與隱藏功能”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),請把它分享出去讓更多的人看到。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
新聞標(biāo)題:vue如何實(shí)現(xiàn)表單中password輸入的顯示與隱藏功能-創(chuàng)新互聯(lián)
標(biāo)題路徑:http://chinadenli.net/article32/hhepc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃、搜索引擎優(yōu)化、標(biāo)簽優(yōu)化、網(wǎng)站改版、移動(dòng)網(wǎng)站建設(shè)、微信小程序
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容