TimePicker.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <div class="wrap-time">
  3. <TimePicker
  4. class="time-picker"
  5. :value="value"
  6. @focus="onFocus"
  7. @change="onChange"
  8. @blur="onBlur"
  9. />
  10. <span>{{ reactData.tip }}</span>
  11. </div>
  12. </template>
  13. <script lang="ts">
  14. import { defineComponent, reactive, toRefs } from 'vue';
  15. import { TimePicker } from 'ant-design-vue';
  16. import moment from 'moment';
  17. const props = {
  18. value: { type: Object, default: {} },
  19. tip: { type: String, default: '' },
  20. };
  21. export default defineComponent({
  22. components: { TimePicker },
  23. props,
  24. emits: ['change'],
  25. setup(props, { emit }) {
  26. const reactData = reactive({
  27. tip: '',
  28. });
  29. function onFocus() {
  30. reactData.tip = props.tip;
  31. }
  32. function onBlur() {
  33. reactData.tip = '';
  34. }
  35. function onChange(val) {
  36. console.log(`val`, val);
  37. emit('change', val);
  38. }
  39. return {
  40. onFocus,
  41. onBlur,
  42. onChange,
  43. reactData,
  44. moment,
  45. ...toRefs(props),
  46. };
  47. },
  48. });
  49. </script>
  50. <style scoped>
  51. .wrap-time {
  52. display: flex;
  53. }
  54. .wrap-time .ant-time-picker {
  55. width: 65%;
  56. margin-right: 10px;
  57. }
  58. .wrap-time span {
  59. font-size: 13px;
  60. line-height: 250%;
  61. color: gray;
  62. }
  63. </style>