如何使用react-native-calendars为ex(Present,absent)标记多个日期

时间:2019-01-29 07:19:13

标签: javascript react-native

我要在当前和缺席中标记两种不同颜色的日期,在此我将其缺席,但不能将当前日期标记为缺席。 使用库react-native-calendars

 fetchItem(item){

this.setState({Absent:items.filter((item) => item.morning == '0'),});

} 


render () {

    var Absentdates = [];
    for(var i in this.state.Absent){
      Absentdates.push(this.state.Absent[i].date);
    }

    var obj = Absentdates.reduce((c, v) => Object.assign(c, {[v]: {selected: true,marked: true,customStyles: {
      container: {
        backgroundColor: 'red',
        elevation: 4,
      },
      text: {
        color: 'white',
      },
    }},

  }), {});

    return
<Calendar
          style={styles.calendar}
          hideExtraDays
          showEventIndicators
          onMonthChange={(month) => {this.fetchAttendance(month)}}
          markedDates={obj}
          markingType={'custom'}
          hideArrows={false}
          />
}

0 个答案:

没有答案