所以,我想结合面板和对话框,一旦我点击齿轮按钮(显示在图片上),我想要一个对话框弹出。但是它甚至不调用函数showDialog()。代码的大部分重要部分如下所示,在图片之后。

-Needed函数:
constructor(props){
super(props);
this.state = {
showDialog: false,
idOfPortletLocation: '',
text: '',
portletlocation: []
};
}
showDialog(){
this.setState({ showDialog: true });
}
onOk(){
this.setState({ showDialog: false });
}
onCancel(){
this.setState({ showDialog: false });
}代码的-Render部分:
<Container layout="fit">
<Panel
ref={panel => this.panel = panel}
title= {this.state.text.title}
tools={[
{type: 'minimize', handler: () => this.toolHandler("minimize", this.state.idOfPortletLocation)},
{type: 'maximize', handler: () => this.toolHandler("maximize", this.state.idOfPortletLocation)},
{type: 'close', handler: () => this.toolHandler("close", this.state.idOfPortletLocation)},
{type: 'gear', handler: () => this.showDialog}
]}
bodyPadding={10}
ref="target"
>
{this.state.text.description}
</Panel>
<Dialog
displayed={showDialog}
title="Dialog"
closable
maximizable
closeAction="hide"
maskTapHandler={this.onCancel}
bodyPadding="20"
maxWidth="200"
defaultFocus="#ok"
onHide={() => this.setState({ showDialog: false })}
>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.'
<Button text="Cancel" handler={this.onCancel}/>
<Button itemId="ok" text="OK" handler={this.onOk}/>
</Dialog>
</Container> 发布于 2018-03-13 09:40:14
如果您不调用该函数,您应该:
{type: 'gear', handler: () => this.showDialog(); }https://stackoverflow.com/questions/49252681
复制相似问题