问题描述
antd Modal模态框,如何实现关闭一个模态框,另一个模态框马上打开?
你可以打开codepen 模拟 第一个. 我将我测试的 js 代码贴出来你覆盖过去 看看是不是你要的效果
const { Modal, Button } = antd;
class App extends React.Component {
state = { visible: false };
showModal = () => {
this.setState({
visible: true,
visible2:false
});
};
handleOk = e => {
console.log(e);
this.setState({
visible: false,
});
};
handleCancel = e => {
console.log(e);
this.setState({
visible: false,
visible2: true
});
};
handleOk2 = e => {
console.log(e);
this.setState({
visible2: false,
});
};
handleCancel2 = e => {
console.log(e);
this.setState({
visible2: false,
});
};
render() {
return (
<div>
<Button type="primary" onClick={this.showModal}>
Open Modal
</Button>
<Modal
title="Basic Modal"
visible={this.state.visible}
onOk={this.handleOk}
onCancel={this.handleCancel}
>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Modal>
<Modal
title="Other Modal"
visible={this.state.visible2}
onOk={this.handleOk2}
onCancel={this.handleCancel2}
>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Modal>
</div>
);
}
}
ReactDOM.render(<App />, mountNode);
13 回答12.9k 阅读
7 回答2.1k 阅读
3 回答1.3k 阅读✓ 已解决
2 回答1.3k 阅读✓ 已解决
6 回答1.2k 阅读✓ 已解决
4 回答1.7k 阅读
6 回答1.1k 阅读
上个模态框中的
close
方法触发,调用另一个模态框的open
方法。