我正在为我的 React 应用程序使用“react full calendar”。我想更改星期六和星期日的整个栏的背景颜色。我怎样才能做到这一点?
const {withHtml} = this.state;
return (
<div className="calendar-wrapper ">
<BigCalendar
selectable
events={events}
views={""}
onSelectSlot={event => this.onSelectSlot() }
defaultDate={new Date()}
/>
<SweetAlert
show={withHtml}
btnSize="sm"
title={<span>HTML <small>Title</small>!</span>}
onConfirm={() => this.onConfirm('withHtml')}>
<span>A custom <span style={{color: '#642aff'}}>html</span> message.</span>
</SweetAlert>
</div>
);
最佳答案
您可以使用dayPropGetter
属性来自定义它
你的函数应该是这样的
const customDayPropGetter = (date: Date) => {
if (date.getDate() === 7 || date.getDate() === 6)
return {
className: 'special-day',
style: {
border: 'solid 3px ' + (date.getDate() === 7 ? '#faa' : '#afa'),
},
};
else return {};
};
像这样分配函数
dayPropGetter={customDayPropGetter}
关于javascript - 有什么方法可以在 'React Full Calendar' 中为周六和周日的整列设置背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54212384/