index.js 979 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { VantComponent } from '../../../common/component';
  2. VantComponent({
  3. props: {
  4. title: {
  5. type: String,
  6. value: '日期选择',
  7. },
  8. subtitle: String,
  9. showTitle: Boolean,
  10. showSubtitle: Boolean,
  11. firstDayOfWeek: {
  12. type: Number,
  13. observer: 'initWeekDay',
  14. },
  15. },
  16. data: {
  17. weekdays: [],
  18. },
  19. created() {
  20. this.initWeekDay();
  21. },
  22. methods: {
  23. initWeekDay() {
  24. const defaultWeeks = ['日', '一', '二', '三', '四', '五', '六'];
  25. const firstDayOfWeek = this.data.firstDayOfWeek || 0;
  26. this.setData({
  27. weekdays: [
  28. ...defaultWeeks.slice(firstDayOfWeek, 7),
  29. ...defaultWeeks.slice(0, firstDayOfWeek),
  30. ],
  31. });
  32. },
  33. onClickSubtitle(event) {
  34. this.$emit('click-subtitle', event);
  35. },
  36. },
  37. });