You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

59 lines
1.1 KiB

  1. <template>
  2. <view class="cu-form-group">
  3. <view class="title">
  4. <text v-if="required" class="lr-required">*</text>
  5. {{ title }}
  6. </view>
  7. <picker
  8. @change="change"
  9. :value="value"
  10. :start="start"
  11. :end="end"
  12. :disabled="disabled"
  13. :class="[disabled ? '' : 'picker-arrow']"
  14. mode="time"
  15. >
  16. <view class="picker">
  17. <slot>{{ value || displayPlaceholder }}</slot>
  18. </view>
  19. </picker>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. name: 'l-time-picker',
  25. props: {
  26. title: {},
  27. start: { default: '00:00' },
  28. end: { default: '23:59' },
  29. disabled: {},
  30. placeholder: {},
  31. required: {},
  32. value: {}
  33. },
  34. methods: {
  35. change(e) {
  36. this.$emit('input', e.detail.value)
  37. this.$emit('change', e.detail.value)
  38. }
  39. },
  40. computed: {
  41. displayPlaceholder() {
  42. if (this.disabled) {
  43. return ''
  44. }
  45. if (this.placeholder) {
  46. return this.placeholder
  47. }
  48. return this.title ? `请选择${this.title}` : '请选择…'
  49. }
  50. }
  51. }
  52. </script>