美文网首页
next.js - window is not defind 解

next.js - window is not defind 解

作者: 海丰 | 来源:发表于2019-07-15 15:02 被阅读0次

使用next.js在引入其他组件或者模块可能会出现报错

ReferenceError: window is not defined
...

解决方法

使用next动态引入模块或组件

import <模块名> from 'next/dynamic';
const Module = dynamic(
    import('<模块名>'),
    { ssr: false }
);

使用模块或组件

<Module>

or

Module()

相关文章

网友评论

      本文标题:next.js - window is not defind 解

      本文链接:https://www.haomeiwen.com/subject/zvynkctx.html