我正在尝试使用这个反应类(react-date-range)来导入日期范围选择器组件,但是当我选择日期时,日期不会更新到两个输入字段中。谁能帮我识别和解决它?
下面的代码和沙箱:
import React from "react";
import "./styles.css";
import { render } from "react-dom";
import { DateRangePicker } from 'react-date-range';
import 'react-date-range/dist/styles.css'; // main style file
import 'react-date-range/dist/theme/default.css'; // theme css file
export default class App extends React.Component {
handleSelect(ranges){
console.log(ranges);
}
render(){
const selectionRange = {
startDate: new Date(),
endDate: new Date(),
key: 'selection',
}
return (
<DateRangePicker
ranges={[selectionRange]}
onChange={this.handleSelect}
/>
)
}
}
render(<App />, document.querySelector("#root"));
沙盒链接: https ://codesandbox.io/s/pedantic-kapitsa-trglh?file=/src/App.js
慕工程0101907
繁星coding
相关分类