Vue.js setInterval
home
Run
screen_rotation
fullscreen
cloud_download
<!DOCTYPE html> <html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.js"></script> </head> <body> <div id="app"> {{message}} </div> <script> new Vue({ el: '#app', data: { message:"" }, methods:{ testFunction: function () { var v = this; setInterval(function () { v.message = new Date().toLocaleTimeString(); }, 2000); } }, mounted () { this.testFunction() } }); </script> </body> </html>
<!DOCTYPE html> <html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.js"></script> </head> <body> <div id="app"> {{message}} </div> <script> new Vue({ el: '#app', data: { message:"" }, methods:{ testFunction: function () { var v = this; setInterval(function () { v.message = new Date().toLocaleTimeString(); }, 2000); } }, mounted () { this.testFunction() } }); </script> </body> </html>
Copyrights@tutorialsplane.com