使用next.js在引入其他組件或者模塊可能會(huì)出現(xiàn)報(bào)錯(cuò)
ReferenceError: window is not defined
...
解決方法
使用next動(dòng)態(tài)引入模塊或組件
import <模塊名> from 'next/dynamic';
const Module = dynamic(
import('<模塊名>'),
{ ssr: false }
);
使用模塊或組件
<Module>
or
Module()