Skip to content
# t-text-date

TextDate 日期文本

t-text-date 组件介绍 ​

t-text-date 是用于格式化显示日期时间的文本组件,支持自定义日期格式,适用于需要显示格式化日期的场景。

t-text-date 平台兼容 ​

HarmonyH5AndroidiOS小程序UTS
✅✅✅✅✅✅

t-text-date 基础用法 ​

基础用法参考 demo/text-date/text-date.uvue。

vue
<template>
	<view class='p-15'>
		<tui-theme-switch></tui-theme-switch>
		<t-card title="Text 文本"
				class="mb-15"
				sub-title="丰富的主题色,支持日期格式化,敏感信息隐藏,金额格式化处理,高亮文本显示,且支持插槽高亮显示"></t-card>
		<t-section title="日期格式化"
				   class='mb-15' />
		<view :class="[`mb-15 r-10 tvg p-10`]">
			<t-text-date type="info"
						 class="mb-8">2023-01-02T02:03:05</t-text-date>
			<t-text-date type="warning"
						 class="mb-8">2023/01/02 02:03:05</t-text-date>
			<t-text-date type="primary"
						 class="mb-8">2023-01-02 02:03:05</t-text-date>
			<t-text-date type="error"
						 class="mb-8"
						 format="d天h时M分s秒">1612959739000</t-text-date>
			<t-text-date type="primary"
						 class="mb-8"
						 format="yyyy-mm-dd">2023-01-02T02:03:05</t-text-date>
			<t-text-date type="primary"
						 class="mb-8"
						 format="yyyy-mm-dd">{{textValue}}</t-text-date>
			<t-button type="success"
					  class="m-15"
					  size='small'
					  @click="test">测试变量</t-button>
		</view>
	</view>
</template>

<script setup>
	import { ref } from 'vue'
	const textValue = ref('1612959739000')
	const test = () => {
		textValue.value = '1602859739000'
	}
</script>

t-text-date Props ​

属性名说明类型默认值
text需要格式化的日期文本string''
format日期格式化格式string'yyyy-mm-dd hh:MM:ss'
path点击组件后跳转的页面路径;为空时仅响应事件string''
hover是否启用点击效果booleantrue
type组件主题类型,可选 info、primary、error、warning、successstring''
disabled是否禁用booleanfalse
effect组件显示主题,可选 normal、dark、light、plainstring''
size组件尺寸,可选 large、medium、small、ministring'medium'

日期格式说明 ​

占位符说明示例
yyyy四位年份2026
mm两位月份03
dd两位日期20
hh两位小时(24小时制)14
MM两位分钟30
ss两位秒00

t-text-date Events ​

事件名说明回调参数
click点击时触发event
initFinished组件初始化完成触发组件节点信息
touchstart触摸开始时触发event
touchend触摸结束时触发event
touchmove触摸移动时触发event
touchcancel触摸取消时触发event