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
To achieve the background color flashing effect, j...
Table of contents 1. Where to write JavaScript 2....
Preface: In MySQL, the system supports many chara...
Preface MySQL supports many types of tables (i.e....
There is an interview question that requires: a th...
step: 1. Create a new docker-compose.yml file in ...
Preface Vue provides a wealth of built-in directi...
Installation suggestion : Try not to use .exe for...
1. Create users and authorize Creating users and ...
This article describes the MySQL single table que...
Preface I believe most people have used MySQL and...
1. Change the virtual machine hardware version in...
Mysql8.0.12 decompression version installation me...
Table of contents 1. What is a regular expression...
Unfortunately, the MYSQL_DATA_TRUNCATED error occ...