index.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <div style="width: 100%">
  3. <VueDatePicker
  4. locale="zh-CN"
  5. :disabled="options?.disabled || false"
  6. :range="options?.range || false"
  7. :model-type="options?.format || 'yyyy.MM.dd'"
  8. :month-picker="month"
  9. :time-picker="time"
  10. :year-picker="year"
  11. :placeholder="options.placeholder ?? '请选择'"
  12. auto-apply
  13. text-input
  14. :show-now-button="options.showToday"
  15. now-button-label="今天"
  16. :enable-time-picker="options.enableTimePicker ?? false"
  17. :clearable="options.clearable ?? true"
  18. :day-names="['一', '二', '三', '四', '五', '六', '七']"
  19. v-bind="$attrs"
  20. ></VueDatePicker>
  21. </div>
  22. </template>
  23. <script setup>
  24. defineOptions({ name: 'date-picker'})
  25. import { computed } from 'vue';
  26. const props = defineProps({
  27. width: {
  28. type: [String, Number],
  29. default: 300
  30. },
  31. options: {
  32. type: Object,
  33. default: () => {}
  34. }
  35. })
  36. const year = computed(() => {
  37. return props.options.type === 'year'
  38. })
  39. const month = computed(() => {
  40. return props.options.type === 'month'
  41. })
  42. const time = computed(() => {
  43. return props.options.type === 'time'
  44. })
  45. </script>
  46. <style scoped lang="scss">
  47. </style>