由于官方没有给出这个x的点击事件的监听hook,所以只能自己曲线救过。
根据文档说明:
onSearch
The callback function triggered when you click on the search-icon, the clear-icon or press the Enter key
可以了解到onSearch的触发条件。
然后通过event对象进行触发类型的判断。
onSearch = (value, event) => {
if (event.nativeEvent.type === 'click' && value === '') {
// listen click
setTimeout(() => {
// TODO
}, 300);
}
if (event.nativeEvent.type === 'enter' && value === '') {
// Enter
setTimeout(() => {
// TODO
}, 300);
}
if (value === '') {
return;
}
// search
};