next.js与antd-form使用时Form中initialValues无法获取localStorage
1.next.js与antd-form一起使用时Form中initialvalues(表单的默认值)无法获取localStorage。
因为next渲染return中的标签是ssr(服务端渲染模式),这里是获取不到localStorage的需要在_app.tsx中关闭next.js默认的ssr渲染
import type { AppProps } from 'next/app'
import 'antd/dist/reset.css'
import '../styles/vars.css'
import '../styles/global.css'
import "../styles/index.css"
import dynamic from 'next/dynamic'
const DynamicSidebarWithNoSSR = dynamic(() => import('./'), {
ssr: false
});
function MyApp({ Component, pageProps }: AppProps) {
return <DynamicSidebarWithNoSSR {...pageProps} />
}
export default MyApp