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>
相关推荐
詩句☾⋆᭄南笙4 分钟前
HTML的盒子模型
前端·html·盒子模型
落言6 分钟前
AI 时代的工程师:懂,却非懂的时代
前端·程序员·架构
一枚攻城狮8 分钟前
前端知识点大汇总
前端
paopaokaka_luck1 小时前
基于SpringBoot+Vue的社区诊所管理系统(AI问答、webSocket实时聊天、Echarts图形化分析)
vue.js·人工智能·spring boot·后端·websocket
余道各努力,千里自同风1 小时前
el-input 输入框宽度自适应宽度
javascript·vue.js·elementui
Mike_jia1 小时前
DumbAssets:开源资产管理神器,家庭与企业的高效管家
前端
Southern Wind2 小时前
Vue 3 多实例 + 缓存复用:理念及实践
前端·javascript·vue.js·缓存·html
一大树2 小时前
Vue3优化指南:少写代码,多提性能
vue.js
HuangYongbiao2 小时前
Rspack 原理:webpack,我为什么不要你
前端
yinuo2 小时前
前端项目开发阶段崩溃?试试这招“Node 内存扩容术”,立马复活!
前端