index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <uni-shadow-root class="weapp-lib-calendar-components-header-index"><view class="van-calendar__header">
  3. <block v-if="showTitle">
  4. <view class="van-calendar__header-title"><slot name="title"></slot></view>
  5. <view class="van-calendar__header-title">{{ title }}</view>
  6. </block>
  7. <view v-if="showSubtitle" class="van-calendar__header-subtitle" @click="onClickSubtitle">
  8. {{ subtitle }}
  9. </view>
  10. <view class="van-calendar__weekdays">
  11. <view v-for="(item,index) in (weekdays)" :key="item.index" class="van-calendar__weekday">
  12. {{ item }}
  13. </view>
  14. </view>
  15. </view></uni-shadow-root>
  16. </template>
  17. <script>
  18. global['__wxRoute'] = 'weapp/lib/calendar/components/header/index'
  19. "use strict";
  20. var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
  21. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  22. if (ar || !(i in from)) {
  23. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  24. ar[i] = from[i];
  25. }
  26. }
  27. return to.concat(ar || Array.prototype.slice.call(from));
  28. };
  29. Object.defineProperty(exports, "__esModule", { value: true });
  30. var component_1 = require("../../../common/component");
  31. (0, component_1.VantComponent)({
  32. props: {
  33. title: {
  34. type: String,
  35. value: '日期选择',
  36. },
  37. subtitle: String,
  38. showTitle: Boolean,
  39. showSubtitle: Boolean,
  40. firstDayOfWeek: {
  41. type: Number,
  42. observer: 'initWeekDay',
  43. },
  44. },
  45. data: {
  46. weekdays: [],
  47. },
  48. created: function () {
  49. this.initWeekDay();
  50. },
  51. methods: {
  52. initWeekDay: function () {
  53. var defaultWeeks = ['日', '一', '二', '三', '四', '五', '六'];
  54. var firstDayOfWeek = this.data.firstDayOfWeek || 0;
  55. this.setData({
  56. weekdays: __spreadArray(__spreadArray([], defaultWeeks.slice(firstDayOfWeek, 7), true), defaultWeeks.slice(0, firstDayOfWeek), true),
  57. });
  58. },
  59. onClickSubtitle: function (event) {
  60. this.$emit('click-subtitle', event);
  61. },
  62. },
  63. });
  64. export default global['__wxComponents']['weapp/lib/calendar/components/header/index']
  65. </script>
  66. <style platform="mp-weixin">
  67. @import '../../../common/index.css';.van-calendar__header{box-shadow:var(--calendar-header-box-shadow,0 2px 10px hsla(220,1%,50%,.16));flex-shrink:0}.van-calendar__header-subtitle,.van-calendar__header-title{font-weight:var(--font-weight-bold,500);height:var(--calendar-header-title-height,44px);line-height:var(--calendar-header-title-height,44px);text-align:center}.van-calendar__header-title+.van-calendar__header-title,.van-calendar__header-title:empty{display:none}.van-calendar__header-title:empty+.van-calendar__header-title{display:block!important}.van-calendar__weekdays{display:flex}.van-calendar__weekday{flex:1;font-size:var(--calendar-weekdays-font-size,12px);line-height:var(--calendar-weekdays-height,30px);text-align:center}
  68. </style>