cl-timeline-item.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="cl-timeline-item" :class="[showLine ? 'show-line' : '']">
  3. <view
  4. class="cl-timeline-item__timestamp"
  5. :style="{
  6. width: `${parent.timestampWidth}rpx`,
  7. }"
  8. >
  9. <slot name="timestamp">
  10. <text class="cl-timeline-item__date">{{ timestampText[0] }}</text>
  11. <text class="cl-timeline-item__time">{{ timestampText[1] }}</text>
  12. </slot>
  13. </view>
  14. <view class="cl-timeline-item__node">
  15. <view class="cl-timeline-item__node-box">
  16. <slot name="icon">
  17. <text
  18. v-if="icon"
  19. class="cl-timeline-item__icon"
  20. :class="[icon]"
  21. :style="{ color }"
  22. ></text>
  23. <text
  24. v-else
  25. class="cl-timeline-item__dot"
  26. :style="{
  27. 'background-color': color || '#999',
  28. }"
  29. ></text>
  30. </slot>
  31. </view>
  32. </view>
  33. <view class="cl-timeline-item__content" select>
  34. <slot name="content">
  35. <text selectable user-select>{{ content }}</text>
  36. </slot>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import Parent from "../../mixins/parent";
  42. /**
  43. * timeline 时间线
  44. * @description 时间线
  45. * @tutorial https://docs.cool-js.com/uni/components/view/timeline.html
  46. * @property {String} timestamp 时间
  47. * @property {String} content 内容
  48. * @property {Boolean} showLine 是否显示竖线
  49. * @property {String} icon 图标
  50. * @property {String} color 图标颜色,默认#999
  51. * @example 见教程
  52. */
  53. export default {
  54. name: "cl-timeline",
  55. componentName: "ClTimelineItem",
  56. props: {
  57. // 时间
  58. timestamp: String,
  59. // 内容
  60. content: String,
  61. // 是否显示竖线
  62. showLine: Boolean,
  63. // 图标
  64. icon: String,
  65. // 图标颜色,默认#999
  66. color: {
  67. type: String,
  68. default: "#999",
  69. },
  70. },
  71. mixins: [Parent],
  72. data() {
  73. return {
  74. ComponentName: "ClTimeline",
  75. Keys: ["timestampWidth"],
  76. };
  77. },
  78. computed: {
  79. timestampText() {
  80. return (this.timestamp || "").split(" ");
  81. },
  82. },
  83. };
  84. </script>