-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathdateformat.vue
47 lines (44 loc) · 1.47 KB
/
dateformat.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<template>
<view>
<uni-card :is-shadow="false" is-full>
<text class="uni-h6">日期格式化组件,通常用于需要展示友好的日期格式的场景。</text>
</uni-card>
<uni-section title="基础用法" type="line" padding>
<view class="example-body">
<uni-dateformat :date="now - 7200000"></uni-dateformat>
<uni-dateformat date="2020/12/12"></uni-dateformat>
</view>
</uni-section>
<uni-section title="设置阈值" subTitle="阈值用于控制什么时候显示刚刚|马上,什么时候显示xx分钟前|xx分钟后" type="line" padding>
<view class="example-body">
<uni-dateformat :date="now - 30000" :threshold="[0,3600000]"></uni-dateformat>
<uni-dateformat :date="now - 30000" :threshold="[0,0]"></uni-dateformat>
</view>
</uni-section>
<uni-section title="使用英文" type="line" padding>
<view class="example-body">
<uni-dateformat :date="now - 1200000" :threshold="[60000,3600000]" locale="en"></uni-dateformat>
<uni-dateformat :date="now - 30000" :threshold="[60000,3600000]" locale="en"></uni-dateformat>
<uni-dateformat :date="now - 80000" :threshold="[60000,3600000]" locale="en"></uni-dateformat>
</view>
</uni-section>
</view>
</template>
<script>
export default {
data() {
return {
now: Date.now()
}
},
methods: {
}
}
</script>
<style lang="scss">
.example-body {
display: flex;
flex-direction: column;
line-height: 1.5em;
}
</style>