vue+elementUi 實(shí)現(xiàn)密碼顯示/隱藏+小圖標(biāo)變化功能
vue+elementUi 實(shí)現(xiàn)密碼顯示/隱藏+小圖標(biāo)變化(js一共三行代碼,其中一行為了美觀)...,先給大家展示下效果圖,感覺(jué)不錯(cuò)可以參考實(shí)現(xiàn)代碼。
【效果圖】



【html】
// 前后代碼【略】 <el-form-item label="密碼" prop="pwd"> <el-input v-model="ruleForm.pwd" :type="pwdType" placeholder="請(qǐng)輸入密碼" @keyup.enter.native="login"> <i slot="suffix" class="el-icon-view" @click="showPwd"></i> </el-input> </el-form-item>
【js】
showPwd () {
this.pwdType === 'password' ? this.pwdType = '' : this.pwdType = 'password';
let e = document.getElementsByClassName('el-icon-view')[0];
this.pwdType == '' ? e.setAttribute('style', 'color: #409EFF') : e.setAttribute('style', 'color: #c0c4cc');
},
ps:下面看下vue+element-ui實(shí)現(xiàn)顯示隱藏密碼
<template>
<el-form :model="cuser_info" label-width="115px" label-position="left" >
<el-row :gutter="20">
<el-col :span="24">
<el-form-item v-if="visible2" label="確認(rèn)密碼" prop="confirm_pwd">
<el-input type="password" v-model="cuser_info.confirm_pwd" placeholder="請(qǐng)?jiān)俅屋斎朊艽a">
<i slot="suffix" title="顯示密碼" @click="changePass('show',2)" style="cursor:pointer;"
class="iconfont icon-xianshizy"></i>
</el-input>
</el-form-item>
<el-form-item v-else label="確認(rèn)密碼" class="is-required" prop="confirm_pwd">
<el-input type="text" v-model="cuser_info.confirm_pwd" placeholder="請(qǐng)?jiān)俅屋斎朊艽a">
<i slot="suffix" title="隱藏密碼" @click="changePass('hide',2)" style="cursor:pointer;"
class="iconfont icon-yincangby"></i>
</el-input>
</el-form-item>
</el-col>
</el-form>
</template>
<script>
export default {
name: "AddC_user",
data(){
return{
cuser_info:{
confirm_pwd:'',
},
visible2: true,
}
},
methods:{
//控制密碼顯示隱藏
changePass(value,kind) {
this.visible2 = !(value === 'show');
},
},
}
</script>
總結(jié)
以上所述是小編給大家介紹的vue+elementUi 實(shí)現(xiàn)密碼顯示/隱藏+小圖標(biāo)變化功能,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺(jué)得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
相關(guān)文章
vue實(shí)現(xiàn)樣式之間的切換及vue動(dòng)態(tài)樣式的實(shí)現(xiàn)方法
這篇文章主要介紹了vue中如何實(shí)現(xiàn)樣式之間的切換及vue動(dòng)態(tài)樣式的實(shí)現(xiàn)方法,本文給大家介紹的非常詳細(xì),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-12-12
Vscode如何創(chuàng)建vue項(xiàng)目
這篇文章主要介紹了Vscode如何創(chuàng)建vue項(xiàng)目問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2025-04-04
vue3+element?plus中利用el-menu如何實(shí)現(xiàn)路由跳轉(zhuǎn)
這篇文章主要給大家介紹了關(guān)于vue3+element?plus中利用el-menu如何實(shí)現(xiàn)路由跳轉(zhuǎn)的相關(guān)資料,在Vue?Router中我們可以使用el-menu組件來(lái)實(shí)現(xiàn)菜單導(dǎo)航,通過(guò)點(diǎn)擊菜單項(xiàng)來(lái)跳轉(zhuǎn)到不同的路由頁(yè)面,需要的朋友可以參考下2023-12-12
AntV+Vue實(shí)現(xiàn)導(dǎo)出圖片功能
AntV?組織圖操作完畢以后,需要點(diǎn)擊按鈕將畫(huà)布以圖片的形式導(dǎo)出,這篇文章主要介紹了AntV結(jié)合Vue實(shí)現(xiàn)導(dǎo)出圖片功能,需要的朋友可以參考下2023-01-01

