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_916008892 小时前
深入解析iOS机审4.3原理与混淆实战方法
android·java·开发语言·ios·小程序·uni-app·iphone
QT.qtqtqtqtqt3 小时前
uni-app小程序前端开发笔记(更新中)
前端·笔记·小程序·uni-app
喵喵虫13 小时前
uniapp修改封装组件失败 styleIsolation
uni-app
游戏开发爱好者81 天前
日常开发与测试的 App 测试方法、查看设备状态、实时日志、应用数据
android·ios·小程序·https·uni-app·iphone·webview
2501_915106321 天前
app 上架过程,安装包准备、证书与描述文件管理、安装测试、上传
android·ios·小程序·https·uni-app·iphone·webview
2501_915106321 天前
使用 Sniffmaster TCP 抓包和 Wireshark 网络分析
网络协议·tcp/ip·ios·小程序·uni-app·wireshark·iphone
宠友信息1 天前
2025社交+IM及时通讯社区APP仿小红书小程序
java·spring boot·小程序·uni-app·web app
“负拾捌”1 天前
python + uniapp 结合腾讯云实现实时语音识别功能(WebSocket)
python·websocket·微信小程序·uni-app·大模型·腾讯云·语音识别
局外人LZ2 天前
Uniapp脚手架项目搭建,uniapp+vue3+uView pro+vite+pinia+sass
前端·uni-app·sass
2501_915918412 天前
在 iOS 环境下查看 App 详细信息与文件目录
android·ios·小程序·https·uni-app·iphone·webview