dateformat.vue 1.4 KB

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