1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-09-12 16:40:40 +08:00
Files
uni-halo/.agents/skills/uniapp-project/examples/uni-ui/uni-dateformat.vue
T
2026-08-31 07:58:23 +08:00

69 lines
1.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!--
日期格式化 组件示例
官方文档https://uniapp.dcloud.net.cn/component/uniui/uni-dateformat.html
插件市场https://ext.dcloud.net.cn/plugin?name=uni-dateformat
-->
<template>
<view class="container">
<uni-card is-full :is-shadow="false">
<text class="uni-h6">日期格式化组件用于日期格式化显示</text>
</uni-card>
<uni-section title="基础用法" type="line" padding>
<view class="example-body">
<uni-dateformat :date="currentDate" />
</view>
</uni-section>
<uni-section title="自定义格式" type="line" padding>
<view class="example-body">
<uni-dateformat :date="currentDate" format="YYYY-MM-DD" />
<uni-dateformat :date="currentDate" format="YYYY/MM/DD HH:mm:ss" />
<uni-dateformat :date="currentDate" format="MM月DD日" />
</view>
</uni-section>
<uni-section title="相对时间" type="line" padding>
<view class="example-body">
<uni-dateformat :date="pastDate" :threshold="[0, 0]" />
<uni-dateformat :date="recentDate" :threshold="[0, 0]" />
</view>
</uni-section>
<uni-section title="时间戳" type="line" padding>
<view class="example-body">
<uni-dateformat :date="timestamp" />
<uni-dateformat :date="timestamp" format="YYYY-MM-DD HH:mm:ss" />
</view>
</uni-section>
</view>
</template>
<script>
export default {
data() {
return {
currentDate: new Date(),
pastDate: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000),
recentDate: new Date(Date.now() - 2 * 60 * 60 * 1000),
timestamp: Date.now()
}
},
methods: {}
}
</script>
<style lang="scss">
.container {
padding: 10px;
}
.example-body {
display: flex;
flex-direction: column;
gap: 15px;
}
</style>