1. 弹窗销毁后再打开,原来的值仍存在,如何销毁弹窗内容?
加destroyOnClose
属性,关闭时销毁子元素。再次打开内容就清空了~
<Modal
title="新增对账流水"
visible={visible}
onOk={() => {
formRef.current.handleSubmit();
}}
onCancel={onClose}
okText="确认"
cancelText="取消"
width={800}
destroyOnClose // 关闭时销毁子元素
>
如果是使用antd中的form,上述方法不起效时,将form重置:
form.resetFields(); // hooks中
或者
this.props.form.resetFields(); // class中
如果有ref,可以这样:this.formRef.current.resetFields();
2. 在Select组件options中找到目标项的value。
通常下拉的结构是:
options = [ { id:1,name:'zhangsan' },...]
findName=(val,options)=>{
const targetoption = options.find(item=> item.value=>val);
return targetoption.name;
}
3.以前文章:React学习之antd中getFieldDecorator的使用
React学习之antd中getFieldDecorator的使用
开发在继续,
持续更新中……
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。