//引入vue.js
<script src="../../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
<script>
 new Vue({
		el: '#ID',
		data:{
		gettime:""
		},
		mounted: function() {
		      var _this = this;
		      let yy = new Date().getFullYear();
		      let mm = new Date().getMonth()+1;
		      let dd = new Date().getDate();
		      let hh = new Date().getHours();
		      let mf = new Date().getMinutes()<10 ? '0'+new Date().getMinutes() : new Date().getMinutes();
		      let ss = new Date().getSeconds()<10 ? '0'+new Date().getSeconds() : new Date().getSeconds();
		      _this.gettime = yy+'-'+mm+'-'+dd+' '+hh+':'+mf+':'+ss;
		      console.log(this.gettime)
		},
		
		});
</script>

输出结果:
在这里插入图片描述

Logo

前往低代码交流专区

更多推荐