index.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <view >
  3. <view class="d-flex a-center j-between">
  4. <u-input :value="value" disabled :placeholder="placeholder" @tap="handleClick"/>
  5. <u-button
  6. @click="handleClick"
  7. type="primary"
  8. size="mini"
  9. >选择</u-button>
  10. </view>
  11. <u-calendar v-model="show" :mode="mode" @change="confirm" max-date="2222-02-02"></u-calendar>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. name: 'MyCalendar',
  17. data() {
  18. return {
  19. show:false
  20. }
  21. },
  22. props: {
  23. placeholder: {
  24. type: String,
  25. default: '请选择'
  26. },
  27. disabled:{
  28. default:false
  29. },
  30. mode:{
  31. type: String,
  32. default: 'date'
  33. },
  34. value: {
  35. type: String | Number
  36. }
  37. },
  38. methods: {
  39. confirm(e) {
  40. this.$emit('input', String(e.result))
  41. this.$emit('change', e.result)
  42. this.show = false
  43. },
  44. handleClick(){
  45. if(this.disabled) return
  46. this.show=true
  47. }
  48. }
  49. }
  50. </script>
  51. <style>
  52. </style>