This article example shares the specific code of Vue to realize user login switching for your reference. The specific content is as follows Switching has problems Code <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div id="app"> <span v-if="isUser"> <label for="username">User Account</label> <input type="text" id="username" placeholder="User account"> </span> <span v-else> <label for="email">User mailbox</label> <input type="text" id="email" placeholder="User email"> </span> <button @click="isUser = !isUser">Switch type</button> </div> <script src="../js/vue.js"></script> <script> const app = new Vue({ el: '#app', data: { isUser: true } }) </script> </body> </html> Effect display Problems
Why does this problem occur? This is because when Vue renders the DOM , for performance reasons, it will reuse existing elements as much as possible instead of creating new elements. Solution
Perfect version login example Add different keys in input Code <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div id="app"> <span v-if="isUser"> <label for="username">User Account</label> <input type="text" id="username" placeholder="User account" key="username"> </span> <span v-else> <label for="email">User mailbox</label> <input type="text" id="email" placeholder="User email" key="email"> </span> <button @click="isUser = !isUser">Switch type</button> </div> <script src="../js/vue.js"></script> <script> const app = new Vue({ el: '#app', data: { isUser: true } }) </script> </body> </html> Effect display The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Detailed explanation of redundant and duplicate indexes in MySQL
>>: Detailed explanation of the role of explain in MySQL
1. Enter the command mysqld --skip-grant-tables (...
The default table name is base_data and the json ...
Just add the following code to achieve it. Method ...
Table of contents WXS Response Event Plan A Page ...
1. Merge the margins of sibling elements The effe...
Table of contents 1. Task Queue 2. To explain som...
This article shares with you a detailed tutorial ...
When using MySQL, dates are generally stored in f...
Table of contents text LOCK parameter ALGORITHM p...
After writing these six articles, I started to fee...
To achieve this effect, you must first know a pro...
Previously, we knew several attributes of backgro...
0. Overview Zabbix is an extremely powerful ope...
Install related dependencies npm i lib-flexible -...
Table of contents Start Docker Stop Docker Python...