seawind8888


  • Home

  • Archives

next.js - window is not defind 解决方法

Posted on 2019-07-15

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

1
2
ReferenceError: window is not defined
...

解决方法

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

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

使用模块或组件

1
<Module>

or

1
Module()
# next.js # nextjs
一图看懂Vue数据绑定原理
koa2+mongo实现小程序同步登陆入库(附轮子)
  • Table of Contents
  • Overview

seawind8888

4 posts
10 tags
  1. 1. 解决方法
© 2019 seawind8888
Powered by Hexo
|
Theme — NexT.Muse v5.1.4