我有两个日历,例如“议程”,有一个图标日历按钮,当我单击它时,它将重定向到另一个日历(Planning),这些日历是使用react-big- calendar开发的,例如当我在juin 17 - 23议程的一周,然后单击图标日历,它将重定向到juin 17 - 23“计划”。
(Planning)
juin 17 - 23
我的代码是:https : //codesandbox.io/s/m7k904y3o8
我尝试使用发送日期getWeek(),但是它不起作用。
getWeek()
我该如何解决?
您可以添加其他数据this.props.history.push,然后可以在组件location上的prop中使用这些数据Planning。例如,如果要查看1995年12月20日的一周:
this.props.history.push
location
Planning
// Agenda.js: Routing to "/planning" this.props.history.push("/planning", { date: new Date(1994, 11, 19, 0, 0)}) // Planning.js constructor(props) { super(props); //Important this.state({ /* ... */ dateWeek: this.props.location.state && this.props.location.state.date }); } // Following is a fix or else you would not get next/previous week. getThisWeek = (dateWeek) => { this.setState({ dateWeek }); }
我建议使用的其他两个解决方案是URL参数和Query参数。