Effect:Ideas:
Page Layout <div id='app'> <!--If the ternary expression pwdFlag is true, type is password and password is hidden. If pwdFlag is false, type is text and password is displayed. --> Password: <input :type='pwdFlag?"password":"text"' size='10'> <!--pwdFlag is true, indicating that the password is hidden, and the eye-open icon is displayed, otherwise the eye-closed icon is displayed--> <img :src='pwdFlag?textIcon:pwdIcon' @click="changePwd" style="width:16px;"> </div> JS code new Vue({ el:'#app', data:{ pwdFlag:true,//Password flag true means the current password is in password form textIcon:'./images/show.jpg',//Show icon pwdIcon:'./images/hide.jpg',//Hide icon}, methods:{ //Change password representation changePwd:function(){ //Reverse the password flag this.pwdFlag=!this.pwdFlag; } } }) Complete code <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <style> </style> <body> <div id='app'> <!--If the ternary expression pwdFlag is true, type is password and password is hidden. If pwdFlag is false, type is text and password is displayed. --> Password: <input :type='pwdFlag?"password":"text"' size='10'> <!--pwdFlag is true, indicating that the password is hidden, and the eye-open icon is displayed, otherwise the eye-closed icon is displayed--> <img :src='pwdFlag?textIcon:pwdIcon' @click="changePwd" style="width:16px;"> </div> </body> <script src="vue.js"></script> <script> new Vue({ el:'#app', data:{ pwdFlag:true,//Password flag true means the current password is in password form textIcon:'./images/show.jpg',//Show icon pwdIcon:'./images/hide.jpg',//Hide icon}, methods:{ //Change password representation changePwd:function(){ //Reverse the password flag this.pwdFlag=!this.pwdFlag; } } }) </script> </html> This concludes this article about the detailed explanation of the idea of implementing password display and hiding functions in Vue. For more relevant content about implementing password display and hiding in Vue, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Alibaba Cloud Centos7.3 installation mysql5.7.18 rpm installation tutorial
>>: Linux kernel device driver kernel debugging technical notes collation
Find the problem I wrote a simple demo before, bu...
Table of contents Preface The need for online XML...
Preface Creating shortcuts in Linux can open appl...
The installation of compressed packages has chang...
Recently, I encountered many problems when deploy...
You can use yum to install all dependencies toget...
All the orchestration files and configuration fil...
Table of contents webpack5 Official Start Buildin...
When we install and configure the server LNPM env...
Preface In daily development, we often encounter ...
<br />The page uses UTF8 encoding, and the h...
Problem phenomenon I recently used sysbench to te...
How to allow remote connection in MySql To achiev...
This is the effect to be achieved: You can see th...
Table of contents Vue+ElementUI background manage...