如果在页面中既没有创建 getStaticProps 也没有创建 getServerSideProps ,页面如何呈现?
How is page rendered if neither getStaticProps nor getServerSideProps is created in a page?
我有一个使用 Next.js 构建的现有项目,但是在某些页面中定义了两种渲染方法中的 none。
如果 getStaticProps
和 getServerSideProps
都不存在,这些页面将如何呈现?
如果页面不包含任何数据获取方法(getStaticProps
/getServerSideProps
),那么它将使用静态生成。这意味着 Next.js 在构建时生成页面 HTML,此 HTML 将在对页面的每个请求中重复使用。
来自 Static Generation without data 文档:
By default, Next.js pre-renders pages using Static Generation without
fetching data.
(...) In cases like this, Next.js generates a single HTML file per
page during build time.
我有一个使用 Next.js 构建的现有项目,但是在某些页面中定义了两种渲染方法中的 none。
如果 getStaticProps
和 getServerSideProps
都不存在,这些页面将如何呈现?
如果页面不包含任何数据获取方法(getStaticProps
/getServerSideProps
),那么它将使用静态生成。这意味着 Next.js 在构建时生成页面 HTML,此 HTML 将在对页面的每个请求中重复使用。
来自 Static Generation without data 文档:
By default, Next.js pre-renders pages using Static Generation without fetching data.
(...) In cases like this, Next.js generates a single HTML file per page during build time.