diff --git a/README.md b/README.md index bc19f12..c2604d8 100644 --- a/README.md +++ b/README.md @@ -84,46 +84,44 @@ const App = () => ( ## 🔨 Usage for SSR ##### 如:create-next-app -项目根目录创建components文件夹,并在其中创建Header.js +创建文件`./pages/_document.js` ```jsx -import React from 'react' -import Head from 'next/head' +import Document, { Html, Head, Main, NextScript } from 'next/document' -const Header = () => ( -
- - - - - -
-) +class MyDocument extends Document { + static async getInitialProps(ctx) { + const initialProps = await Document.getInitialProps(ctx) + return { ...initialProps } + } -export default Header + render() { + return ( + + {/* */} + + + + +
+ + + + ) + } +} + +export default MyDocument ``` ```jsx import dynamic from 'next/dynamic' - -const DynamicComponentWithNoSSR = dynamic(import('../components/Header'), { - ssr: false -}) - const ReactLive2d = dynamic(import('react-live2d'), { ssr: false }) export default function Home() ( <> -