每次尝试使用浅选项在URL中更新或添加queryParms时,页面都会呈现。有时会出错
提供的
as
值(null)与href
值(/ search / [country] / [city])不兼容
对于动态路由,我的文件夹结构为
Search -> Folder Name
- [country]
- [city].js
当我尝试更新点击时的网址
const incrementCounter = () => {
const currentCounter = query.counter ? parseInt(query.counter) : 0;
const href = `/search/de/berlin/?counter=${currentCounter + 1}`;
router.push(pathname, href, { shallow: true });
};
就我而言,在单击更改状态计数器时,路由器中的查询对象未使用计数器params.so更新,因此,如果我再次单击,则它不会递增。
第二种情况,如果我将路径名替换为asPath,那么我的URL正在更新,而查询参数也在更新。问题是页面每次在服务器上呈现。
重现行为的步骤:
我当前的网址-http://localhost:4000/search/de/berlin
想要添加新的queryParams:?counter=3&id=98
不应在服务器上重新加载页面。应该是路由器查询中的所有参数。
系统信息