vue---打印本地当前时间Demo

css 复制代码
<template>
	<view class="content" @tap="getCurrentTime()">
		打印时间
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello'
			}
		},
		onLoad() {

		},
		methods: {
			getCurrentTime() {
				          //获取当前时间并打印
				          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>

<style>
	.content {
		text-align: center;
		height: 400upx;
		margin-top: 200upx;
	}
</style>
相关推荐
橘子星2 分钟前
别再懵圈!JS 执行机制的 “千层套路” 全揭秘
前端·javascript
GuWenyue2 分钟前
LeetCode 76 最小覆盖子串|JS 滑动窗口标准解法
前端·算法·面试
YHHLAI4 分钟前
前端 HTTP 请求 & LLM 接口开发
前端·网络协议·http
拾年2756 分钟前
__proto__ vs prototype:90% 的人分不清的 JavaScript 核心
前端·javascript·面试
国科安芯6 分钟前
国科安芯推出商业航天级抗辐照半双工 RS485 收发器 ASC485S2Y
前端·单片机·嵌入式硬件·架构·安全性测试
丑过三八线7 分钟前
Umi 运行时配置 app.tsx 详解
前端
提子拌饭13323 分钟前
个人月事记录表应用 - 鸿蒙PC Electron框架完整实现指南
前端·javascript·华为·electron·前端框架·开源·鸿蒙系统
超人气王30 分钟前
新手学前端JS浅拷贝和深拷贝:对象复制竟然是个“替身文学”?
javascript·面试
YHL31 分钟前
📚 JS执行机制(执行上下文 + 调用栈 + 编译流程)
前端·javascript
不简说36 分钟前
这次真香!sv-print 可视化打印设计器更新:插件脚手架、Excel 导出、弹窗 API 三连发
前端·javascript·前端框架