1. Two-way bindingTwo-way binding means that if your front-end data changes, the data in your data will also change. Similarly, if the data in your data changes, the data in the front-end page will also change. Moreover, this process does not require refreshing. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div id="app"> <!-- What you input will be displayed, in fact, the front-end data changes, and the message will change accordingly--> Input text: <input type="text" v-model="message">{{message}} </div> <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.min.js"></script> <script> var vm = new Vue({ el: "#app", data: { message: "" } }); </script> </body> </html> Running results: If the data in data is changed, the data in the front-end page will also change, as shown below: If the front-end data changes, the data in your data will also change. As shown below: 2. Will the same result occur when other tags are selected? The answer is of course yes:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div id="app"> gender: <input type="radio" name="sex" value="Male" v-model="message"> Male<input type="radio" name="sex" value="Female" v-model="message"> Female<p>Your gender is: {{message}}</p> </div> <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.min.js"></script> <script> var vm = new Vue({ el: "#app", data: { message: "" } }); </script> </body> </html> Running results: 3. Let’s look at another one:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div id="app"> <select v-model="select"> <option value="" disabled>--Please select--</option> <option>Male</option> <option>Female</option> </select> <span>Your choice: {{select}}</span> </div> <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.min.js"></script> <script> var vm = new Vue({ el: "#app", data: { select: "" } }); </script> </body> </html> Running results: 4. Note SummarizeThis article ends here. I hope it can be helpful to you. I also hope you can pay more attention to more content on 123WORDPRESS.COM! You may also be interested in:
|
<<: Overview and Introduction to Linux Operating System
>>: Basic understanding and use of HTML select option
01. Command Overview dirname - strip non-director...
Use HTML color blocks to dynamically display data...
1. Create a configuration file directory cd /home...
After starting Docker, let's take a look at t...
1.fullpage.js Download address https://github.com...
Many of my friends may encounter a problem and do...
Table of contents 1. Replace the apply method, ge...
Documentation: https://github.com/hilongjw/vue-la...
1. Problem Forgot password for mysql5.7 under lin...
In this section, the author describes the special...
Table of contents 1. Teleport 1.1 Introduction to...
vue-router has two modes hash mode History mode 1...
Table of contents 1. Definition and Use 1.1 Defin...
Table of contents Introduction to bootstrap and i...
1. When ffmpeg pushes video files, the encoding f...