uniapp使用uview - DatetimePicker 时间选择器 /时间戳转化

uniapp使用uview - DatetimePicker 时间选择器 /时间戳转化时转换日期格式后页面仍显示时间戳

单元格内显示时间,点击可出现时间选择器切换时间

javascript 复制代码
<u-cell :isLink=true @click="selectTime" title="开始时间" :value="startTime"></u-cell>

	<u-datetime-picker :show="showSelectTime" v-model="startTime" mode="datetime"
			@cancel="showSelectTime = false" @confirm="confirmTime"></u-datetime-picker>
javascript 复制代码
data() {
			return {
	//start是获取当前时间,或者接口有返回数据,不然选择器时间会是2014年的
   startTime: Number(new Date()),
   showSelectTime: false,
     }
	},

methpds:{
		// 点击选择单元格展示时间组件
			selectTime(e) {
				console.log('点击了', e);
				this.showSelectTime = true;
			},
			// 点击时间选择器的确定
			//这里使用的是一个异步的方法,直接赋值数据的话格式是转换了,但是页面上仍然显示时间戳
			async confirmTime(e) {
				let timeValue = await uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM');
				this.startTime = timeValue;
				console.log(this.startTime, '展示时间');
				this.showSelectTime = false;

			},
}
	onLoad() {
//对应了 data中的startTime: Number(new Date()),
//初始化页面时转换时间格式,否则渲染展示的是时间戳
			this.startTime = uni.$u.timeFormat(this.startTime, 'yyyy-mm-dd hh:MM');
}
相关推荐
云上凯歌11 小时前
01_AI工具平台项目概述.md
人工智能·python·uni-app
郑州光合科技余经理11 小时前
O2O上门预约小程序:全栈解决方案
java·大数据·开发语言·人工智能·小程序·uni-app·php
2501_9160088911 小时前
在不越狱前提下导出 iOS 应用文件的过程,访问应用沙盒目录,获取真实数据
android·macos·ios·小程序·uni-app·cocoa·iphone
2501_9151063211 小时前
Android和IOS 移动应用App图标生成与使用 Assets.car生成
android·ios·小程序·https·uni-app·iphone·webview
木子啊12 小时前
UNIAPP移动端瀑布流列表,支持APP、微信小程序、H5
uni-app·瀑布流·两列排序
2501_9159184112 小时前
Mac 抓包软件有哪些?Charles、mitmproxy、Wireshark和Sniffmaster哪个更合适
android·ios·小程序·https·uni-app·iphone·webview
2501_9151063212 小时前
iOS 抓包绕过 SSL 证书认证, HTTPS 暴力抓包、数据流分析
android·ios·小程序·https·uni-app·iphone·ssl
WeiAreYoung12 小时前
uni-app xcode 制作iOS Notification Service Extension 远程推送图文原生插件
ios·uni-app·xcode
2501_9159214320 小时前
iOS App 电耗管理 通过系统电池记录、Xcode Instruments 与克魔(KeyMob)组合使用
android·ios·小程序·https·uni-app·iphone·webview
2501_915918411 天前
iOS App 测试方法,Xcode、TestFlight与克魔(KeyMob)等工具组合使用
android·macos·ios·小程序·uni-app·iphone·xcode