【发布时间】:2021-05-06 08:35:42
【问题描述】:
我使用静态设置标记日期,但不知道如何通过循环动态设置
代码:
const markedDatesArray = [
{
date: moment('2021-01-22', 'YYYY-MM-DD'),
dots: [
{
color: COLORS.GREEN,
},
],
},
{
date: moment('2021-01-20', 'YYYY-MM-DD'),
dots: [
{
color: COLORS.GREEN,
},
],
},
];
<CalendarStrip
calendarAnimation={{type: 'sequence', duration: 30}}
minDate={start}
maxDate={end}
daySelectionAnimation={{
type: 'background',
duration: 200,
highlightColor: COLORS.GREEN,
}}
onDateSelected={(date) => console.log(date)}
markedDates={markedDatesArray}
style={styles.calenderStrip}
calendarHeaderStyle={styles.calendarHeaderStyle}
calendarColor={COLORS.WHITE}
dateNumberStyle={styles.dateNumberStyle}
dateNameStyle={styles.dateNameStyle}
highlightDateNumberStyle={styles.highlightDateNumberStyle}
highlightDateNameStyle={styles.highlightDateNameStyle}
iconContainer={{flex: 0.1}}
datesBlacklist={datesBlacklist}
/>
如何动态设置, 从 api 获取的日期是:
["2021-02-10", "2021-02-11", "2021-02-11", "2021-02-12"]
【问题讨论】:
标签: android arrays reactjs react-native loops