代码实例
<html lang="en"> <head> <meta set="UTF-8"> <title>vue.js时间刷新</title> </head> <body> <div id="app"> {{date}} </div> <script src="https://www.jq22.com/jquery/vue.min.js"></script><script> var app=new Vue({ el:'#app', data:{ date:new Date() }, mounted:function(){ var _this=this; this.timer=setInterval(function(){ _this.date=new Date(); },1000)}, beforDestroy:function(){ if(this.timer){ clearInterval(this.timer); } } }) </script> </body> </html>