请帮我解决以下问题,我使用的是 react 15.4.0,react-bootstrap 0.32.1,
我需要从模式(这是一个由按钮触发的组件)中显示一个日期选择器(Bootstrap)。
我已经尝试在输入上使用 refs 但无济于事(componentDidMount() 上的 this.refs 为空 {});
由于这是一个子组件,因此 componentDidMount() 在父组件之前被调用(不是按需调用,因此当我尝试单击我的输入时,DOM 上不存在该元素)
呼叫者:
<ModalRequestChange key={'request-change' + row.id} id={row.id} props={this.props} />
模态组件:
componentDidMount() {
var date_input = $('input[name="date"]');
var options = {
format: 'mm/dd/yyyy',
showMeridian: true,
todayHighlight: true,
autoclose: true,
todayBtn: true,
startDate: new Date(),
minuteStep: 4,
position: "bottom left",
origin: "top left",
orientation: "right",
};
date_input.datepicker(options).on('changeDate', (e) => {
this.handleChange(e);
});
}
render() {
return (
<div>
{this.state.isLoading ? <Loader/>: ''}
<Modal backdrop={'static'} attentionClass={''} show={this.props.show} onHide={this.close} backdrop='static' keyboard={false} attentionClass={''}>
<Modal.Header closeButton>
<Modal.Title>Edit Request Campaign</Modal.Title>
</Modal.Header>
<Modal.Body>
<div>Please use this form to modify your request.</div>
<form ref="form">
<div className="row">
</div>
</div>
</div>
</form>
</Modal.Body>
</Modal>
</div>
);
}
提前致谢。
心有法竹
智慧大石
随时随地看视频慕课网APP
相关分类