react ant 通过置空按钮,在外部通过js清空Select和RangePicker的值
作者:互联网
可以给 RangePicker 控件设置一个key,通过将key设置为new Date() 达到清空目的
const [keyValue, setKeyValue] = useState('');
return (
<div>
<RangePicker key={keyValue}
/>
<button onClick={()=>{
setKeyValue(new Date());
}}>重置</button>
</div>
)
而Select则是自己通过获取原生Dom元素:
document.getElementsByClassName('ant-select-selection-item')[0].innerText = ""
标签:RangePicker,js,ant,keyValue,setKeyValue,Date,new 来源: https://blog.csdn.net/qq_41160739/article/details/120649912