当我从‘下一步/导航?’导入useRouter
时,我收到以下错误:
类型‘AppRouterInstance’上不存在属性‘Query’.
import { useRouter } from 'next/navigation';
const {
query: { id },
back
} = useRouter();
如果我使用旧的‘下一步/路由’,在浏览器中是I get this error.我怎么才能解决这个问题呢?
当我从‘下一步/导航?’导入useRouter
时,我收到以下错误:
类型‘AppRouterInstance’上不存在属性‘Query’.
import { useRouter } from 'next/navigation';
const {
query: { id },
back
} = useRouter();
如果我使用旧的‘下一步/路由’,在浏览器中是I get this error.我怎么才能解决这个问题呢?
这是因为‘Query’对象已从useRouter钩子中删除.所以现在,您必须使用‘useSearchParams()’.查看新文档here