11import React from 'react'
22import { AtButton , AtCalendar } from 'taro-ui'
3+ import dayjs from 'dayjs'
34import { View } from '@tarojs/components'
45import Taro from '@tarojs/taro'
56import DocsHeader from '../../components/doc-header'
@@ -21,7 +22,8 @@ interface IndexState {
2122 [ key : string ] : any
2223}
2324
24- export default class Index extends React . Component < { } , IndexState > {
25+ interface IndexProps { }
26+ export default class Index extends React . Component < IndexProps , IndexState > {
2527 public config : Taro . PageConfig = {
2628 navigationBarTitleText : 'Taro日历组件展示'
2729 }
@@ -86,14 +88,8 @@ export default class Index extends React.Component<{}, IndexState> {
8688 }
8789
8890 public render ( ) : JSX . Element {
89- const {
90- now,
91- minDate,
92- maxDate,
93- mark,
94- multiCurentDate,
95- validDates
96- } = this . state
91+ const { now, minDate, maxDate, mark, multiCurentDate, validDates } =
92+ this . state
9793 return (
9894 < View className = 'page calendar-page' >
9995 < DocsHeader title = 'Calendar 日历' />
@@ -211,6 +207,22 @@ export default class Index extends React.Component<{}, IndexState> {
211207 < AtCalendar validDates = { validDates } />
212208 </ View >
213209 </ View >
210+
211+ < View className = 'panel' >
212+ < View className = 'panel__title' > 禁用日期</ View >
213+ < View className = 'panel__content' >
214+ < AtCalendar
215+ disabledDate = { ( currentDate : dayjs . Dayjs ) => {
216+ const yesterday = dayjs ( ) . subtract ( 1 , 'day' )
217+ const tomorrow = dayjs ( ) . add ( 1 , 'day' )
218+ return (
219+ dayjs ( currentDate ) . isSame ( yesterday , 'day' ) ||
220+ dayjs ( currentDate ) . isSame ( tomorrow , 'day' )
221+ )
222+ } }
223+ />
224+ </ View >
225+ </ View >
214226 </ View >
215227 </ View >
216228 )
0 commit comments