【发布时间】:2017-12-12 05:44:57
【问题描述】:
接下来的代码使用了一个 Modal react 组件:
export class AddWorkLogEditor extends React.Component {
constructor(props) {
super(props);
this.addWorkLog = this.addWorkLog.bind(this);
this.onOpenModal = this.onOpenModal.bind(this);
this.onCloseModal = this.onCloseModal.bind(this);
this.state = {
open:true
};
}
onOpenModal() {
this.setState({open: this.props.openModal});
}
onCloseModal() {
this.setState({open:false});
}
addWorkLog() {
}
render() {
const bstyle = {
backgroundColor: 'green',
textAlign:"left",
paddingLeft: '0px',
color: 'white'
};
const {open} = this.state;
return (
<div>
<Modal open={open} onClose={this.onCloseModal} little>
<h3>hi gi</h3>
<Button bsStyle="success" bsSize="small" onClick ={(ev) => {console.log(ev)} }> Save </Button>
</Modal>
</div>
);
}
}
我正在尝试使用:
addWorkLog()
{
return <AddWorkLogEditor/>;
}
和
createAddWorkLogButton () {
return (
<button style={ { color: '#007a86'} } onClick={this.addWorkLog} >Add Work Log</button>
);
}
我的意思是,单击此按钮后,什么都没有显示。还有另一种方式来调用该模态吗?我正在从以下位置导入模态:
从“react-responsive-modal”导入模态
【问题讨论】:
标签: reactjs ecmascript-6 modal-dialog jsx