Skip to content
#

es5-javascript

Here are 99 public repositories matching this topic...

yaofly2012
yaofly2012 commented Feb 26, 2020

_document.js

  1. nextjs有自己的HTML生成规则,Page组件不需要(也不应该)包含html, head, body这些顶层的DOM结构。
  2. Document组件只在服务端执行(客户端不会执行),客户端直接使用生成的DOM结构。
  3. 个人觉得Document不属于SSR范畴,SSR更强调同构,而Document组件更像是传统的服务端渲染。
  4. 可以认为Document组件给nextJs应用生成了统一的DOM壳,整个nextjs应用的SSR和客户端渲染都是在这个DOM壳里进行的:
<div id="__next"></div>

一、Document.getInitailProps

1.1 实参ctx

跟Page组件一样,但多了个属性renderPage

1.2 返回值

Improve this page

Add a description, image, and links to the es5-javascript topic page so that developers can more easily learn about it.

Curate this topic

Add this topic to your repo

To associate your repository with the es5-javascript topic, visit your repo's landing page and select "manage topics."

Learn more

You can’t perform that action at this time.