fuchengshen
2022-06-22 9fa82135f46592776883a9913dc2f3d126ccf1c2
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
<template>
    <span class="cl-date">{{ value }}</span>
</template>
 
<script lang="ts">
import { defineComponent, computed } from "vue";
import dayjs from "dayjs";
 
export default defineComponent({
    name: "cl-date",
 
    props: {
        modelValue: [String, Number],
        format: {
            type: String,
            default: "YYYY-MM-DD HH:mm:ss"
        }
    },
 
    setup(props) {
        const value = computed(() => {
            return props.modelValue ? dayjs(props.modelValue).format(props.format) : "";
        });
 
        return {
            value
        };
    }
});
</script>