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>
相关推荐
x***13391 小时前
【MyBatisPlus】MyBatisPlus介绍与使用
android·前端·后端
z***75154 小时前
【Springboot3+vue3】从零到一搭建Springboot3+vue3前后端分离项目之后端环境搭建
android·前端·后端
fruge5 小时前
仿写优秀组件:还原 Element Plus 的 Dialog 弹窗核心逻辑
前端
an86950015 小时前
vue新建项目
前端·javascript·vue.js
w***95496 小时前
SQL美化器:sql-beautify安装与配置完全指南
android·前端·后端
顾安r6 小时前
11.22 脚本打包APP 排错指南
linux·服务器·开发语言·前端·flask
万邦科技Lafite6 小时前
1688图片搜索商品API接口(item_search_img)使用指南
java·前端·数据库·开放api·电商开放平台
czhc11400756636 小时前
c# 1121 构造方法
java·javascript·c#
yinuo7 小时前
网页也懂黑夜与白天:系统主题自动切换
前端
Coding_Doggy8 小时前
链盾shieldchain | 项目管理、DID操作、DID密钥更新消息定时提醒
java·服务器·前端