uniapp 的 uni-dateformat 获取时间_data 获取格式化后的时间

 前言

在使用uniapp开发移动端时,可以通过插件uni-dateformat格式化时间,本文讲的是如何获取格式化后的时间,传递给后台。

在uniapp官网示例中,没有说如何获取到uni-dateformat格式化后的数据,该方法实在论坛中找到的,亲测可以使用

效果

代码

<template>
	<view class="">
		<uni-dateformat :date="nowTime" format="yyyy-MM-dd hh:mm:ss" ref="ymdHms"></uni-dateformat>
	</view>
</template>
<script>
   export default {
     data() {
		return { nowTime: Date.now(),}
     },
     mounted(){
        //生命周期不要变

        let tim=this.$refs.ymdHms.dateShow;
	console.log('tim',tim)
     }

   }
</script>

  

完成

posted @ 2022-05-13 21:36  大笛子  阅读(1507)  评论(0编辑  收藏  举报