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');
}
相关推荐
2501_916008897 小时前
iOS开发APP上架全流程解析:从开发到App Store的完整指南
android·ios·小程序·https·uni-app·iphone·webview
酷酷的鱼8 小时前
2026 跨平台开发终极选型:Flutter, React Native 与 uni-app x 深度博标与规划指南
flutter·react native·uni-app
biyezuopinvip8 小时前
基于uni-app和Express的问答对战小程序的设计与实现(论文)
小程序·uni-app·毕业设计·论文·express·毕业论文·问答对战小程序的设计与实现
2501_915909061 天前
Charles 抓不到包怎么办?iOS 调试过程中如何判断请求路径
android·ios·小程序·https·uni-app·iphone·webview
2501_916007471 天前
iOS和iPadOS文件管理系统全面解析与使用指南
android·ios·小程序·https·uni-app·iphone·webview
卜锦元1 天前
EchoChat搭建自己的音视频会议系统01-准备工作
c++·golang·uni-app·node.js·音视频
敲敲了个代码1 天前
让 Vant 弹出层适配 Uniapp Webview 返回键
前端·javascript·vue.js·学习·面试·uni-app
2501_915921431 天前
iOS App 开发阶段性能优化,观察 CPU、内存和日志变化
android·ios·性能优化·小程序·uni-app·iphone·webview
木子啊1 天前
UNIAPP国内房贷计算器
uni-app·房贷·房贷计算器·房贷利率·公积金贷款·商业贷款
游戏开发爱好者81 天前
在 iOS 开发、测试与上架过程中 如何做证书管理
android·ios·小程序·https·uni-app·iphone·webview