我要在当前和缺席中标记两种不同颜色的日期,在此我将其缺席,但不能将当前日期标记为缺席。 使用库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}
/>
}