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
Table of contents Preface About webSocket operati...
Due to work requirements, I recently spent some t...
MySQL is a relatively easy-to-use relational data...
Preview: Code: Page Sections: <template> &l...
English: A link tag will automatically complete h...
Database backup #grammar: # mysqldump -h server-u...
Apple Mug Icons and Extras HD StorageBox – add on...
Currently encountering such a problem My situatio...
There are two ways to run .sh files in Linux syst...
Write a SQL first SELECT DISTINCT from_id FROM co...
Preface This article mainly introduces the method...
Table of contents Project Creation Project Struct...
Before starting the main text of this article, yo...
Table of contents this Method In the object Hidde...
Five delay methods for MySQL time blind injection...