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>
相关推荐
六月June June4 小时前
自定义调色盘组件
前端·javascript·调色盘
SY_FC4 小时前
实现一个父组件引入了子组件,跳转到其他页面,其他页面返回回来重新加载子组件函数
java·前端·javascript
糟糕好吃4 小时前
我让 AI 操作网页之后,开始不想点按钮了
前端·javascript·后端
陈天伟教授5 小时前
人工智能应用- 天文学家的助手:08. 星系定位与分类
前端·javascript·数据库·人工智能·机器学习
VaJoy5 小时前
给到夯!前端工具链新标杆 Vite Plus 初探
前端·vite
颜酱6 小时前
BFS 与并查集实战总结:从基础框架到刷题落地
javascript·后端·算法
小彭努力中6 小时前
191.Vue3 + OpenLayers 实战:可控化版权信息(Attribution)详解与完整示例
前端·javascript·vue.js·#地图开发·#cesium
奇舞精选6 小时前
用去年 github 最火的 n8n 快速实现自动化推送工具
前端·agent
奇舞精选6 小时前
实践:如何为智能体推理引入外部决策步骤
前端·agent
无限大67 小时前
AI实战02:一个万能提示词模板,搞定90%的文案/设计/分析需求
前端·后端