如何获取开始日期和结束日期的值?我用:
import { DateRangePickerComponent } from '@syncfusion/ej2-react-calendars';
这是一个重复的问题,因为我想分别获取开始日期和结束日期。
import { DateRangePickerComponent } from '@syncfusion/ej2-react-calendars';
import { makeStyles } from '@material-ui/core/styles';
const [startdate, setStartDate] = useState("");
const [enddate, setEndDate] = useState("");
const onChangedate = (props) => {
const stateDate = props.startDate;
const endDate = props.endDate;
setStartDate(stateDate)
setEndDate(endDate)
};
const handleUpdateButton = async ()=> {
console.log(startdate, enddate) // I just want to print here the start date and end date
}
<Grid item xs={12} sm={6} md={6} lg={6} style={{padding: 15, paddingBottom: 0, alignItems: 'center'}}>
<DateRangePickerComponent id="daterangepicker" change={onChangedate} placeholder='Select a range' style={{paddingTop: 10, fontSize: 16}}/>
</Grid>
<Grid item xs={12} style={{padding: 8}}>
<Button onClick={handleUpdateButton} variant="contained"color="primary" fullWidth>
Apply Filters
</Button>
</Grid>