我选择输入,然后它还会显示相关文本以解决此问题。请帮助我
这是我尝试过的
fetch('http://sample/?keyword='+searchText+'')
.then(res => res.json())
.then(async (json) => {
const { contactList: data } = json;
this.setState({ data });
});
const { data } = this.state;
const regex = new RegExp(`${searchText.trim()}`, 'i');
return data.filter(item => item.Name.search(regex) > -1);