0

是否可以在 react-native-calendars 议程中呈现每天的事件计数而不是一个点?假设我一天有 2 个事件,那么数字 2 应该显示在该日期下方。任何示例将不胜感激。

4

1 回答 1

0

用dayComponent解决了它:

render() {
return  (
   <Agenda
    ....
    dayComponent={renderDayComponent}
    .....>
  </Agenda>)
}

renderDayComponent = data => <CalendarDayComponent {...data} calendarData={calendarData} />;

恢复 onPress 行为:

const CalendarDayComponent => props {
    onPressed = () => {
        requestAnimationFrame(() => props.onPress(props.date));
    }
    let items = '';

    if (props.marking.marked) {
        items = calendarData[date.dateString].length
    }
return (
        <View style={styles.container}>
            <Text onPress={onPressed} style={{ color: state === 'disabled' ? 'gray' : 'black' }}>
                {children}
            </Text>
            <Text style={styles.itemsCount}>
                {items}
            </Text>
        </View>
    )
};
于 2019-09-25T06:12:31.350 回答