fs-timeago.vue 595 B

12345678910111213141516171819202122232425262728293031323334
  1. <template>
  2. <view @click="handleClick">{{ timeago(dateTime, format) }}</view>
  3. </template>
  4. <script>
  5. /**
  6. * 多久之前组件
  7. * @description 多久之前组件
  8. * @property {String, Number, Object} dateTime 日期
  9. * @property {String} format 格式化
  10. */
  11. export default {
  12. name: 'fs-timeago'
  13. }
  14. </script>
  15. <script setup>
  16. import timeago from '@/utils/timeago'
  17. const props = defineProps({
  18. dateTime: [String, Number, Object],
  19. format: {
  20. type: String,
  21. default: 'YYYY-MM-DD'
  22. }
  23. })
  24. const emits = defineEmits(['click'])
  25. const handleClick = () => {
  26. emits('click')
  27. }
  28. </script>
  29. <style></style>