【问题标题】:Warning Prop `href` did not match警告 Prop `href` 不匹配
【发布时间】:2021-11-26 03:54:16
【问题描述】:

我在另一个动态页面路由之后有一个动态页面路由。我只收到第二个动态页面路由的警告。

Warning: Prop `href` did not match. Server: "/books/category/[category]/filter/[filter]#" Client: "/books/category/literatura-oastei/filter/ceva#"

如何解决这个警告?

【问题讨论】:

    标签: next.js href server-side-rendering getstaticpaths nextjs-dynamic-routing


    【解决方案1】:

    我必须在getStaticPaths 函数中使用设置为blockingfallback 属性。

    例子:

    export const getStaticPaths: GetStaticPaths = async () => {
      return {
        paths: [],
        fallback: 'blocking'
      };
    };
    

    详细了解fallback 属性here

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-30
    • 1970-01-01
    • 2021-06-14
    • 1970-01-01
    • 2018-12-28
    相关资源
    最近更新 更多