我正在尝试在自动完成搜索栏上显示一些选项,并且当我单击某个选项时,我试图将其重定向到另一个页面,但是到目前为止,我还无法做到这一点。请记住,我正在使用Next.js。
export default function SearchBar() {
const store = useSelector((store: RootState) => store.pokeStore);
function handleInputChange(event, value) {
Router.push(`/pokemons/${value}`);
}
return (
<div>
<Autocomplete
id="combo-box-demo"
options={store}
getOptionLabel={(option: string) => option}
style={{ width: 300 }}
onInputChange={handleInputChange}
renderInput={(params) => <TextField {...params} variant="outlined" fullWidth />}
/>
</div>
);
}