0

用ant design pro 框架做的项目,有一个需求,当选择月份了以后自动生成当月所有的星期天的日期展示出来,

clipboard.png

1个回答

0

已采纳
import moment from 'moment';


<MouthPicker onChange={value => {
      let day = value.startOf('month').valueOf();
      let sundays = [];
      for (; day < value.endOf('month').valueOf(); day = moment(day).add(1, 'days').valueOf()) {
        if(moment(day).day() === 0) {
          sundays.push(moment(day));
          console.log(moment(day).format('YYYY-MM-DD'));
        }  
      }
    }}/>

在线调试

撰写答案

Planets