![](/img/trans.png)
[英]Agenda which is added to the calendar is fine with Week view but in month view it is coming one day earlier in US
[英]Changing view from month to week or day or agenda crashes the app react big calendar
錯誤:從每月或每周或每天或議程更改視圖會使應用程序崩潰。 我懷疑這與時刻有關。
我的代碼
import { Calendar, momentLocalizer } from "react-big-calendar";
import moment from "moment";
import "react-big-calendar/lib/css/react-big-calendar.css";
const localizer = momentLocalizer(moment);
const Calendars = () => {
return (
<div>
<Calendar events={events} startAccessor="start_date" endAccessor="end_date" defaultDate={ new Date()} localizer={localizer} />
</div>
);
};
樣本數據
這是我傳遞給日歷function 的數據
cost events = [
{
"title": "Work",
"start_date": "2020-02-10T09:00:00.000Z",
"end_date": "2020-02-10T11:00:00.000Z"
},
{
"title": "Work",
"start_date": "2020-02-08T09:00:00.000Z",
"end_date": "2020-02-08T11:00:00.000Z"
}
]
我可能做錯了什么?
您應該將“start_date”和“end_date”轉換為 js 日期 object => moment(start_date).toDate()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.