先給大家分享效果圖:


具體實現代碼如下所示:
html:
<group> <span>設置密碼</span> <x-input :type="this.registration_data.pwdType" placeholder="請填寫密碼" @on-change="password"></x-input> <img :src="this.registration_data.src" @click="changeType()"/></group>
script:
data () { return { registration_data:{ pwdType:"password", src:require("../assets/colse_eyes.png") } }},methods:{changeType(){ this.registration_data.pwdType = this.registration_data.pwdType==='password'?'text':'password'; this.registration_data.src=this.registration_data.src==require("../assets/colse_eyes.png")?require("../assets/open_eyes.png"):require("../assets/colse_eyes.png");}}注:帶小眼睛的睜開閉合。
總結
以上所述是小編給大家介紹的vue實現密碼顯示隱藏切換功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!
新聞熱點
疑難解答