Vue's simple timer is for your reference. The specific contents are as follows Principle: setInterval is used to run the self-increment method every 1s (settable time interval), and clearInterval is used to stop the continuously running self-increment method to achieve the function of the timer. In the Vue part, the real-time refresh view function of Vue is used to display the value of the auto-increment variable on the front end. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Time</title> <script src="js/vue.js" type="text/javascript" charset="utf-8"></script> </head> <body> <div id="app"> <input type="button" name="" id="" value="Start" @click="start"/></br> <h1>{{number}}</h1> <input type="button" name="" id="" value="Pause" @click="stop"/></br> </div> <script type="text/javascript"> var vm = new Vue({ el:"#app", data:{ number:0 }, methods:{ start:function(){ time = setInterval(function(){ vm.number++ },1000) }, stop:function(){ clearInterval(time) } } }) </script> </body> </html> Rendering 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:
|
<<: MySQL dual-machine hot standby implementation solution [testable]
question: The following error occurred when insta...
Table of contents Overview 1. Develop the require...
This article mainly introduces the Vue project. O...
1. Install Python 3 1. Install dependency package...
Table of contents Create a simple springboot proj...
Table of contents 1. Anonymous slots 2. Named slo...
So-called talent (left brain and right brain) Tha...
Table of contents Same Origin Policy Ajax request...
Unzip the Maven package tar xf apache-maven-3.5.4...
Special symbols Named Entities Decimal encoding S...
I'll record the problems I encountered during...
A common development need is that we want to coll...
Here I use samba (file sharing service) v4.9.1 + ...
Table of contents What is the slow query log? How...
Table of contents The background is: What will ha...