index.vue 980 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <uni-datetime-picker
  3. ref="calendarRef"
  4. v-model="innerValue"
  5. :type="type"
  6. @change="confirm"
  7. :hide-second="hideSecond"
  8. >
  9. <text></text>
  10. </uni-datetime-picker>
  11. </template>
  12. <script>
  13. export default {
  14. props: {
  15. value: {
  16. type: String | Number | Array,
  17. default: function() {
  18. return null
  19. }
  20. },
  21. //展示格式
  22. type: {
  23. type: String,
  24. default: 'datetimerange'
  25. },
  26. hideSecond: {
  27. type: Boolean,
  28. default: true
  29. },
  30. },
  31. watch: {
  32. value: {
  33. handler(newVal) {
  34. this.innerValue = newVal
  35. }
  36. },
  37. innerValue: {
  38. handler(newVal) {
  39. this.$emit('input', newVal)
  40. }
  41. },
  42. },
  43. computed: {
  44. },
  45. data() {
  46. return {
  47. innerValue: null,
  48. }
  49. },
  50. onReady() {
  51. },
  52. methods: {
  53. show() {
  54. this.$refs.calendarRef.show()
  55. },
  56. reset() {
  57. this.innerValue = null;
  58. },
  59. confirm(e) {
  60. this.$emit('confirm',e)
  61. },
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. </style>