gpt4 book ai didi

javascript - ExtReact 中未调用对话框

转载 作者:行者123 更新时间:2023-11-30 20:41:10 25 4
gpt4 key购买 nike

所以,我想将 Panel 与 Dialog 结合起来,一旦我点击齿轮按钮(如图所示),我想要弹出一个对话框。但好像它甚至没有调用函数 showDialog()。代码的最重要部分如下所示,位于图片之后。

enter image description here

-需要的功能:

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 });
}

-渲染部分代码:

<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>

最佳答案

你不是在调用函数,你应该:

{type: 'gear', handler: () => this.showDialog(); }

关于javascript - ExtReact 中未调用对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49252681/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com