DateExample.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <div>
  3. <h1>日期控件</h1>
  4. <h2>基本表单</h2>
  5. <div>
  6. <div class="form-group">
  7. <label for="datetime">日期</label>
  8. <Date
  9. v-model="dateValue0"
  10. @update:model-value="getNewDate"
  11. />
  12. </div>
  13. </div>
  14. {{ dateValue0 }} 更改次数 {{ changedCount0 }}
  15. <div>
  16. <div class="form-group">
  17. <label for="datetime">日期(日期时间强制转换)</label>
  18. <Date
  19. v-model="dateValue1"
  20. @update:model-value="changedCount1++"
  21. />
  22. </div>
  23. </div>
  24. {{ dateValue1 }} 更改次数 {{ changedCount1 }}
  25. <h2>内联表单</h2>
  26. <div class="form-inline">
  27. <div class="form-group">
  28. <label
  29. class="control-label"
  30. for="inputGroupSuccess3"
  31. >日期</label>
  32. <Date
  33. v-model="dateValueV2"
  34. />
  35. </div>
  36. </div>
  37. {{ dateValueV2 }}
  38. <h2>只读</h2>
  39. <div class="form-inline">
  40. <div class="form-group">
  41. <label
  42. class="control-label"
  43. for="inputGroupSuccess3"
  44. >日期</label>
  45. <Date
  46. v-model="dateValueV3"
  47. :readonly="true"
  48. />
  49. </div>
  50. </div>
  51. {{ dateValueV3 }}
  52. </div>
  53. </template>
  54. <script>
  55. import Date from '@/date/index.js';
  56. export default {
  57. name: 'DateExample',
  58. components: {
  59. Date,
  60. },
  61. data: function () {
  62. return {
  63. dateValue0: '2021-10-08',
  64. changedCount0: 0,
  65. dateValue1: '2021-10-09 17:54:00',
  66. changedCount1: 0,
  67. dateValueV2: '2021-10-09',
  68. changedCount2: 0,
  69. dateValueV3: '2022-10-09',
  70. changedCount3: 0,
  71. };
  72. },
  73. methods: {
  74. getNewDate(date) {
  75. console.log(date);
  76. this.changedCount0++;
  77. },
  78. },
  79. };
  80. </script>
  81. <style>
  82. </style>