如何在Material UI Library中以编程方式关闭日期/时间选择器?
答案 0 :(得分:1)
这会起作用 autoOk={true}
。有关详细信息,请参阅此 github 问题
答案 1 :(得分:0)
import React from 'react';
import DatePickerDialog from 'material-ui/DatePicker/DatePickerDialog';
export default class SomeComponent extends React.Component {
constructor(props, context) {
super(props, context);
this.closeDatePicker = this.closeDatePicker.bind(this);
this.openDatePicker = this.openDatePicker.bind(this);
}
closeDatePicker() {
this.datePicker.dismiss();
}
openDatePicker() {
this.datePicker.show();
}
render() {
return (
<div>
<button onClick={this.openDatePicker}>Open</button>
<button onClick={this.closeDatePicker}>Close</button>
<DatePickerDialog ref={ref => this.datePicker = ref} />
</div>
);
}
}