我使用React.JS.在v5中有一个日历
我有一个像这样的函数
function handleChangeBackgroundColorCalendar (info) {
info.el.style.backgroundColor = 'red'
}
这个函数让我点击日历上的单元格,颜色也发生了变化。如何再次单击并返回到日历的初始颜色?
。
我这样把函数命名为JSX:
<FullCalendar
id="calendar"
ref={calendarRef}
slotMaxTime="22:00:00"
slotMinTime="07:00:00"
allDaySlot={false}
eventClick={info => {
handleChangeBackgroundColorCalendar(info)
}}
plugins={[resourceTimeGridPlugin, interactionPlugin]}
defaultView="resourceTimeGridDay"
editable={false}
selectable={true}
selectMirror={true}
schedulerLicenseKey={'GPL-My-Project-Is-Open-Source'}
dayMaxEvents={true}
weekends={weekendsVisible}
events={handleLoadInformationsCalendar()}
themeSystem={'bootstrap'}
headerToolbar={{
left: '',
center: '',
right: ''
}}
locale="pt-br"
timeZone='America/Sao_Paulo'
/>
发布于 2020-11-04 18:55:53
您可以定义一个布尔值,它通知您单击事件的偶数/奇数。
const [toggle, setToggle] = useState(false)
...
function handleChangeBackgroundColorCalendar (info) {
info.el.style.backgroundColor = toggle ? 'red' : 'blue'
setToggle(!toggle)
}
https://stackoverflow.com/questions/64690527
复制