React-dates是一个React组件库,用于处理日期选择和日期范围选择。其中的DateRangePicker组件用于选择日期范围。如果在页面上使用了两个DateRangePicker组件,但它们无法正常工作,可能有以下几个原因:
对于以上问题,可以参考以下解决方案:
import { DateRangePicker } from 'react-dates';
<DateRangePicker
startDate={this.state.startDate1}
endDate={this.state.endDate1}
onDatesChange={({ startDate, endDate }) => this.setState({ startDate1, endDate1 })}
focusedInput={this.state.focusedInput1}
onFocusChange={(focusedInput) => this.setState({ focusedInput1 })}
/>
<DateRangePicker
startDate={this.state.startDate2}
endDate={this.state.endDate2}
onDatesChange={({ startDate, endDate }) => this.setState({ startDate2, endDate2 })}
focusedInput={this.state.focusedInput2}
onFocusChange={(focusedInput) => this.setState({ focusedInput2 })}
/>
constructor(props) {
super(props);
this.state = {
startDate1: null,
endDate1: null,
focusedInput1: null,
startDate2: null,
endDate2: null,
focusedInput2: null,
};
}
以上是针对Not working 2 DateRangePicker (react-dates) on 1 page的问题的一般解决方案。如果问题仍然存在,可能需要进一步检查代码和调试。腾讯云没有直接相关的产品和产品介绍链接地址,但可以参考React-dates官方文档(https://github.com/airbnb/react-dates)以获取更多信息和帮助。
领取专属 10元无门槛券
手把手带您无忧上云