[英]Why does getInitialProps runs on redirect but not on page refresh? (NextJS)
一个快速的 NextJS 问题 -> 为什么当页面被重定向到(例如使用 Router.push \\ Router.replace)时 getInitialProps 正在运行,但不是在页面刷新时运行? 这背后的道理是什么?
谢谢!
对于初始页面加载,getInitialProps 将仅在服务器上执行。 getInitialProps 只会在通过 next/link 组件或使用 next/router 导航到不同的路由时在客户端上执行。
这意味着它将在 Initial Page Load -Refreshes Apply- 中被调用,它在服务器端执行,而不是在客户端执行。 作为从
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.