router.push 查询被 url 参数覆盖

问题描述 投票:0回答:1

因此,当我使用 Router.push 时,我用它发送的查询会被覆盖

Router.push({
 pathname: `/product/${subCategoryValue}`,
 query: { category: helpWith, industry: industry },
});

当我在

console.log(query)
页面上
/product/${subCategoryValue}
时,唯一显示的是 url 参数(subCategoryValue)。

next.js
1个回答
1
投票

使用下面的代码修复了它:

Router.push(
  {
    pathname: `/product/${subCategoryValue}`,
    query: { category: helpWith, industry: industryValue },
  },
  `/product/${subCategoryValue}`
);

© www.soinside.com 2019 - 2024. All rights reserved.