countdown.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <el-row>
  3. <el-col :span="8">
  4. <el-countdown title="Start to grab" :value="value" />
  5. </el-col>
  6. <el-col :span="8">
  7. <el-countdown
  8. title="Remaining VIP time"
  9. format="HH:mm:ss"
  10. :value="value1"
  11. />
  12. <el-button class="countdown-footer" type="primary" @click="reset"
  13. >Reset
  14. </el-button>
  15. </el-col>
  16. <el-col :span="8">
  17. <el-countdown format="DD [days] HH:mm:ss" :value="value2">
  18. <template #title>
  19. <div style="display: inline-flex; align-items: center">
  20. <el-icon style="margin-right: 4px" :size="12">
  21. <Calendar />
  22. </el-icon>
  23. Still to go until next month
  24. </div>
  25. </template>
  26. </el-countdown>
  27. <div class="countdown-footer">{{ value2.format('YYYY-MM-DD') }}</div>
  28. </el-col>
  29. </el-row>
  30. </template>
  31. <script lang="ts" setup>
  32. import { ref } from 'vue'
  33. import dayjs from 'dayjs'
  34. import { Calendar } from '@element-plus/icons-vue'
  35. const value = ref(Date.now() + 1000 * 60 * 60 * 7)
  36. const value1 = ref(Date.now() + 1000 * 60 * 60 * 24 * 2)
  37. const value2 = ref(dayjs().add(1, 'month').startOf('month'))
  38. function reset() {
  39. value1.value = Date.now() + 1000 * 60 * 60 * 24 * 2
  40. }
  41. </script>
  42. <style scoped>
  43. .el-col {
  44. text-align: center;
  45. }
  46. .countdown-footer {
  47. margin-top: 8px;
  48. }
  49. </style>