ShowMomentOrNull.vue 769 B

1234567891011121314151617181920212223242526272829303132333435
  1. <template>
  2. <span :class="'vc-show-date '+size">
  3. <span v-if="value && value!=null">
  4. {{ typeof value.format === 'function' ? value.format(dateFormat) : '不是日期类型' }}
  5. </span>
  6. <span v-else class="text-secondary"><i>{{ nullText }}</i></span>
  7. </span>
  8. </template>
  9. <script lang="ts">
  10. import { defineComponent } from 'vue';
  11. import dayjs from 'dayjs';
  12. export default defineComponent({
  13. name: "ShowDateOrNull",
  14. props: {
  15. nullText: {
  16. default: '暂无',
  17. type: String
  18. },
  19. dateFormat: {
  20. default: 'YYYY-MM-DD HH:mm:ss',
  21. type: String
  22. },
  23. size: {
  24. default: '',
  25. type: String
  26. },
  27. value: {
  28. type: Object as import('vue').PropType<dayjs.Dayjs>,
  29. default: null,
  30. }
  31. },
  32. });
  33. </script>