default-time.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <div class="block">
  3. <span class="demonstration">Start and end date time 12:00:00</span>
  4. <el-date-picker
  5. v-model="value1"
  6. type="datetimerange"
  7. start-placeholder="Start Date"
  8. end-placeholder="End Date"
  9. :default-time="defaultTime1"
  10. />
  11. </div>
  12. <div class="block">
  13. <span class="demonstration"
  14. >Start date time 12:00:00, end date time 08:00:00</span
  15. >
  16. <el-date-picker
  17. v-model="value2"
  18. type="datetimerange"
  19. start-placeholder="Start Date"
  20. end-placeholder="End Date"
  21. :default-time="defaultTime2"
  22. />
  23. </div>
  24. </template>
  25. <script lang="ts" setup>
  26. import { ref } from 'vue'
  27. const value1 = ref('')
  28. const value2 = ref('')
  29. const defaultTime1 = new Date(2000, 1, 1, 12, 0, 0) // '12:00:00'
  30. const defaultTime2: [Date, Date] = [
  31. new Date(2000, 1, 1, 12, 0, 0),
  32. new Date(2000, 2, 1, 8, 0, 0),
  33. ] // '12:00:00', '08:00:00'
  34. </script>
  35. <style scoped>
  36. .block {
  37. padding: 30px 0;
  38. text-align: center;
  39. border-right: solid 1px var(--el-border-color);
  40. flex: 1;
  41. }
  42. .block:last-child {
  43. border-right: none;
  44. }
  45. .block .demonstration {
  46. display: block;
  47. color: var(--el-text-color-secondary);
  48. font-size: 14px;
  49. margin-bottom: 20px;
  50. }
  51. </style>