通过使用withRouter HOC让Nexjts组件能够访问next/router。以下是一个示例代码:
import { withRouter } from 'next/router'; const SearchBar = ({ router }) => { // use router }; export default withRouter(SearchBar);
上一篇:Algolia安卓即时搜索在查询更改时无法工作。
下一篇:AlgoliaAutocomplete与TypesenseAdapter一起使用时,出现TypeError:Cannotreadpropertiesofundefined(reading'headers')错误。