This article example shares the specific code of Vue to achieve simple data two-way binding for your reference. The specific content is as follows Here is a simple implementation, which helps novices understand and digest. Of course, Vue is indispensable for realizing two-way data proxy. I look forward to the subsequent update. Vue two-way data binding -> Object.defineProperty() //2.0 core syntax <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> </head> <body> <input type="text" id="ipt" /> <p id="lc"></p> </body> </html> <script> //Get the page element var ipt = document.getElementById("ipt"); var ps = document.getElementById("lc"); var obj = { name: "" }; //The core principle of vue two-way data binding applicationObject.defineProperty(obj, "name", { get() { return ipt.value; }, set(newval) { ipt.value = newval; ps.innerHTML = newval; }, }); //Monitor data changes in input and assign values to p tags ipt.addEventListener("keyup", function() { ps.innerHTML = ipt.value; }); </script> 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:
|
<<: Solve the problem of wireless and audio not working after Windows Server installation
>>: MySQL case when group by example
This article shares the installation tutorial of ...
Image Accelerator Sometimes it is difficult to pu...
1. Warm and gentle Related address: http://www.web...
Click here to return to the 123WORDPRESS.COM HTML ...
JDK download address: http://www.oracle.com/techn...
Mysql8.0.12 decompression version installation me...
Copy code The code is as follows: <!DOCTYPE ht...
Table of contents 1. Introduction to NFS 2. NFS C...
This article shares the MySQL installation tutori...
Table of contents Overview Why choose a framework...
Table of contents 1. Array deduplication 2. Dedup...
The specific code for encapsulating the image cap...
1. Single machine environment construction# 1.1 D...
1. Syntax TIMESTAMPDIFF(unit,begin,end); Returns ...
Monday to Sunday time format conversion (Y --- ye...