Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
318 views
in Technique[技术] by (71.8m points)

关于Input防抖处理问题 react

antd Input里面加了onChange事件,它就会监听用户输入的每一个字符导致不断setState,后面加上防抖,把value属性去掉,问题是已经可以解决,但是如果Input在弹窗里面输入内容,然后把弹窗关掉,再重新打开弹窗,上一次输入的内容还在,请问这个要怎么清除呢?如果加上value属性的话,Input显示框就会有问题。

目前我用了最笨的方法,在Input加入了id属性,在点击弹窗时直接通过dom去清除输入框的内容,暂时没找到更好的解决方法
document.getElementById('xxx').value='';

image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

可以了解下 Modal 的 destroyOnClose 这个属性。
你的 Input 是写在表单里的话,需要 看下 Form 的 preserve 属性,应该可以满足你的需求了。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

62 comments

56.6k users

...