小编Ami*_*_DA的帖子

NextJs:在传递查询字符串时尝试硬导航到相同的 URL 错误

我正在研究 NextJs 版本13.0.2和 ReactJs 版本18.2.0。我想在 URL 中传递查询字符串,但我得到:

Error: Invariant: attempted to hard navigate to the same URL /@workamirdanesh?w=true http://localhost:3000/@workamirdanesh?w=true
Run Code Online (Sandbox Code Playgroud)

当我访问http://localhost:3000/@workamirdaneshURL 时一切正常。但是当我添加像这样的查询字符串:?w=true并且它变成:时http://localhost:3000/@workamirdanesh?w=true,我收到上述错误。

我该如何解决它以及这里的问题是什么?显然,查询字符串不应该抛出错误,并且应该使用查询字符串之前的 URL 加载页面。

更新:我更新了 NextJs 版本13.0.7,问题仍然存在。

javascript url query-string reactjs next.js

15
推荐指数
1
解决办法
2万
查看次数

标签 统计

javascript ×1

next.js ×1

query-string ×1

reactjs ×1

url ×1