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_915918417 小时前
iOS App 测试方法,Xcode、TestFlight与克魔(KeyMob)等工具组合使用
android·macos·ios·小程序·uni-app·iphone·xcode
2501_915921438 小时前
iOS 描述文件制作过程,从 Bundle ID、证书、设备到描述文件生成后的验证
android·ios·小程序·https·uni-app·iphone·webview
2501_9159090621 小时前
如何保护 iOS IPA 文件中资源与文件的安全,图片、JSON重命名
android·ios·小程序·uni-app·json·iphone·webview
2501_915909061 天前
原生与 H5 共存情况下的测试思路,混合开发 App 的实际测试场景
android·ios·小程序·https·uni-app·iphone·webview
游戏开发爱好者81 天前
了解 Xcode 在 iOS 开发中的作用和功能有哪些
android·ios·小程序·https·uni-app·iphone·webview
2501_915106321 天前
iOS 抓包工具实战实践指南,围绕代理抓包、数据流抓包和拦截器等常见工具
android·ios·小程序·https·uni-app·iphone·webview
Jyywww1211 天前
Uniapp+Vue3 移动端顶部安全距离
uni-app
2501_915106321 天前
如何在 iOS 设备上理解和分析 CPU 使用率(windows环境)
android·ios·小程序·https·uni-app·iphone·webview
怀君1 天前
Uniapp——苹果IOS离线打自定义基座教程
ios·uni-app
码农客栈1 天前
小程序学习(十二)之命令行创建uni-app项目
学习·小程序·uni-app