Next js Loader 仅显示页面加载时间,但不显示服务器端渲染组件的页面/导航更改

问题描述 投票:0回答:1
next.js
1个回答
0
投票

删除使用状态挂钩,并将其设为服务器组件。然后,搜索参数将作为 props 传入,假设您至少使用 Next v13,然后将该

onChange
方法更改为导航方法。如果您使用分页库,我几乎肯定它们会允许您自己设置按钮 href,如果您在没有库的情况下执行此操作,只需将这些按钮更改为 Next
Link
s。那会是这样的:

export default function Pagi({searchParams:{page = 1}}) {

    return (
        <Pagination
        isCompact
        showControls
        showShadow
        color="primary"
        page={page}
        total={pages}
        onChange={(page) => {
/// NOTE: replace this with href on each button. You'll have to look at the docs for @next-ui/org to figure out exactly what property that would involve, but it's not `onChange`.
    window.location.href = `/yourPage?page=${page}`
}}
      />
    );
}
© www.soinside.com 2019 - 2024. All rights reserved.