背景:modal组件关闭时不清除数据,原来输入的数据还存在
解决方案:
1、modal的api:destroyOnClose
2、手动控制modal的销毁
1 this.state = { 2 destroy:true //设一开始为不显示状态 3 } 4 5 { 6 this.state.isDestroy 7 ? '' 8 : <Modal className="cjy-rcm-modal" title={this.oprt} footer={null} visible={this.state.visible} onOk={this.handleOk} onCancel={this.handleCancel}> 9 <ReAddScoreOption itemData={this.state.itemData} handleCancel={this.handleCancel} submitData={this.submitData}/> 10 </Modal> 11 } 12 13 显示: 14 this.setState({ 15 destroy:false 16 }); 17 18 销毁: 19 this.setState({ 20 destroy:true 21 });
本文转载自:https://www.cnblogs.com/ruoshuisanqian/p/10402561.html