wxc-page-calendar

Weex 全屏日历组件,支持单程、往返日历的选择,可显示节假日,支持设置附加信息

Demo

wxc-page-calendar 日历 - 图1 wxc-page-calendar 日历 - 图2

使用方法

  1. <template>
  2. <div class="wrapper">
  3. <div class="btn" @click="showCalendar">
  4. <text class="btn-txt">单程日历</text>
  5. </div>
  6. <div class="btn btn-margin yellow" @click="showReturnCalendar">
  7. <text class="btn-txt">往返日历</text>
  8. </div>
  9. <div class="panel">
  10. <text v-if="currentDate" class="text">当前日期: {{currentDate}}</text>
  11. </div>
  12. <wxc-page-calendar :date-range="dateRange"
  13. :animationType="animationType"
  14. :selected-date="selectedDate"
  15. :selected-note="selectedNote"
  16. :is-range="isRange"
  17. :minibar-cfg="minibarCfg"
  18. :desc-list="descList"
  19. @wxcPageCalendarBackClicked="wxcPageCalendarBackClicked"
  20. @wxcPageCalendarDateSelected="wxcPageCalendarDateSelected"
  21. ref="wxcPageCalendar"></wxc-page-calendar>
  22. </div>
  23. </template>
  24. <script>
  25. import { WxcPageCalendar } from 'weex-ui';
  26. export default {
  27. components: {
  28. WxcPageCalendar
  29. },
  30. data: () => ({
  31. animationType: 'push',
  32. currentDate: '',
  33. selectedDate: ['2017-06-23', '2017-06-30'],
  34. isRange: true,
  35. calendarTitle: '选择日期',
  36. dateRange: ['2017-06-10', '2018-06-10'],
  37. selectedNote: ['出发', '到达', '往返'],
  38. minibarCfg: {
  39. title: '日期选择'
  40. },
  41. descList: [
  42. { date: '2017-06-23', value: '¥200' },
  43. { date: '2017-06-24', value: '¥200' },
  44. { date: '2017-06-25', value: '¥200' },
  45. { date: '2017-06-26', value: '¥200' },
  46. { date: '2017-06-27', value: '¥222' },
  47. { date: '2017-06-28', value: '¥341' },
  48. { date: '2017-06-29', value: '¥230' },
  49. { date: '2017-06-30', value: '¥2000' }
  50. ]
  51. }),
  52. methods: {
  53. wxcPageCalendarDateSelected (e) {
  54. this.selectedDate = e.date;
  55. this.currentDate = e.date;
  56. },
  57. wxcPageCalendarBackClicked () {
  58. },
  59. showCalendar () {
  60. this.isRange = false;
  61. setTimeout(() => {
  62. this.$refs['wxcPageCalendar'].show();
  63. }, 10);
  64. },
  65. showReturnCalendar () {
  66. this.isRange = true;
  67. setTimeout(() => {
  68. this.$refs['wxcPageCalendar'].show();
  69. }, 10);
  70. }
  71. }
  72. };
  73. </script>

更详细代码可以参考 demo

可配置参数

Prop Type Required Default Description
date-range Array Y [] 日历范围
selected-date Array N [] 选中日期
is-range Boolean N false 是否是往返日历
selected-note Array N ['开始', '到达', '往返'] 选中提示语
desc-list Array N [{}] 附加信息
show-header Boolean N false 是否在 Native 下显示导航栏
minibar-cfg Object N {} 导航栏 配置,降级版本默认显示
animationType String N push 自定义转场动画类型目前支持model和push

事件回调

  1. // 日期选择
  2. @wxcPageCalendarDateSelected="calendarDateSelect"
  3. // 返回按钮点击
  4. @wxcPageCalendarBackClicked="wxcPageCalendarBackClicked"
  5. // 隐藏日历事件
  6. @wxcPageCalendarHide="wxcPageCalendarHide"

Please feel free to use and contribute to the development.

原文: https://alibaba.github.io/weex-ui/#/cn/packages/wxc-page-calendar/