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');
}
相关推荐
中国胖子风清扬2 天前
GPUI 在 macOS 上编译问题排查指南
spring boot·后端·macos·小程序·rust·uni-app·web app
码云数智-园园3 天前
uni-app 实现物流进度跟踪功能:从 UI 到数据驱动的完整方案
ui·uni-app
予你@。4 天前
UniApp + Vue3 实现 Tab 点击滚动定位(微信小程序)
微信小程序·小程序·uni-app
游戏开发爱好者84 天前
完整教程:App上架苹果App Store全流程指南
android·ios·小程序·https·uni-app·iphone·webview
予你@。4 天前
uni-app progress 组件使用详解
uni-app
iOS阿玮4 天前
春节提审高峰来袭!App Store 审核时长显著延长。
uni-app·app·apple
2501_916007475 天前
ios上架 App 流程,证书生成、从描述文件创建、打包、安装验证到上传
android·ios·小程序·https·uni-app·iphone·webview
2501_915106325 天前
iPhone 文件管理,如何进行应用沙盒文件查看
android·ios·小程序·https·uni-app·iphone·webview
2501_915921436 天前
Fastlane 结合 AppUploader 来实现 CI 集成自动化上架
android·运维·ci/cd·小程序·uni-app·自动化·iphone
云游云记6 天前
vue2 vue3 uniapp (微信小程序) v-model双向绑定
微信小程序·uni-app·vue