小编nin*_*des的帖子

Next js:在后退按钮上单击页面内容未加载

问题:在 React + nextjs 应用程序中

  1. 如果我使用 Link 从http://localhost:3000导航到http://localhost:3000/p/hello
  2. 刷新页面。
  3. 单击后退按钮:它会转到http://localhost:3000但仍然呈现http://localhost:3000/p/hello的内容,它不会加载http://localhost:3000的内容。

我正在使用“下一个”:“^8.1.0”。

导航链接

        <div>
            Click{' '}
            <Link as={`/p/hello`} href={`/postDetails?title=hello`}>
                <a>here</a>
            </Link>
            to read more
        </div>
Run Code Online (Sandbox Code Playgroud)

服务器.js:

const express = require('express')
const next = require('next')

const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()

app
  .prepare()
  .then(() => {
    const server = express()
server.get('/p/:id', (req, res) => {
  const actualPage = '/postDetails'
  const queryParams = { …
Run Code Online (Sandbox Code Playgroud)

reactjs next.js

7
推荐指数
1
解决办法
8092
查看次数

标签 统计

next.js ×1

reactjs ×1