【问题标题】:router.push query getting overwritten by url paramrouter.push 查询被 url 参数覆盖
【发布时间】:2022-08-22 20:44:20
【问题描述】:

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

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

当我在/product/${subCategoryValue} 页面上console.log(query) 时,唯一出现的是url 参数(子类别值)。

  • subCategoryValue 不是查询参数吗?例如:?categoryId=1
  • 但是当我 console.log(query) 它出现在那里
  • 你能告诉我们/product/${subCategoryValue}页面的代码吗?

标签: next.js


【解决方案1】:

使用以下代码修复它:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-16
    • 2022-01-25
    • 2015-06-05
    • 2020-05-31
    • 2017-11-04
    • 2017-08-31
    • 2017-01-14
    • 1970-01-01
    相关资源
    最近更新 更多