0

我有以下代码

constructor(props) {
    super(props);
    this.state = {
        startDate: null,
        endDate: null,
        focusedInput: null
    };
}

render() {
    return (
        <div>
            <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/react-dates@20.2.5/lib/css/_datepicker.css" />

            <DateRangePicker
                startDate={this.state.startDate} // momentPropTypes.momentObj or null,
                startDateId="1" // PropTypes.string.isRequired,
                endDate={this.state.endDate} // momentPropTypes.momentObj or null,
                endDateId="2" // PropTypes.string.isRequired,
                onDatesChange={({ startDate, endDate }) => this.setState({ startDate, endDate })} // PropTypes.func.isRequired,
                focusedInput={this.state.focusedInput} // PropTypes.oneOf([START_DATE, END_DATE]) or null,
                onFocusChange={focusedInput => this.setState({ focusedInput })} // PropTypes.func.isRequired,
            />
        </div>
    );
}

当转到正确的页面时,控件正在工作,但它最初显示为打开状态。我怎样才能让它最初关闭?

4

0 回答 0