我正在尝试在NextJS项目中添加一个页面,该页面包含用于发布一些信息的表单。该页面只能通过单击包装在Link标记中的“添加新”引导按钮来访问。重定向很好,但是当我单击浏览器的后退按钮时,大约需要2分钟才能返回首页(“添加新”按钮)。
这是我的Package.json:
{
"name": "FrontEnd",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@zeit/next-css": "^1.0.1",
"bootstrap": "^4.3.1",
"isomorphic-unfetch": "^3.0.0",
"next": "^9.1.1",
"react": "^16.10.2",
"react-calendar": "^2.19.2",
"react-dom": "^16.10.2"
}
}
我的“主页”页面:
const Index = (props) => (
<Layout>
<ul>
{props.reservas.map(reserva => (
<li>
<ReservaPreview props={reserva.props}/>
</li>
))}
<li><AgregarReservaBoton /></li>
</ul>
</Layout>
);
我的“启动按钮”:
class AgregarReservaBoton extends Component {
render() {
return (
<div>
<Link href='/nuevaReserva'>
<button type="button"></button>
</Link>
</div>
)
}
}
我的“重定向”页面:
const NuevaReserva = (props) => (
<div>
<Layout>
<AgregarReservaForm />
</Layout>
</div>
)
完成进出口。
浏览器的后退按钮工作正常。