我正在使用这个包If I import normally it works fine but I'm getting Blob is not defined since its Nextjs中的“connect”函数
因此,我尝试动态导入它,如下Here I'm getting type error
Argument of type '() => Promise<(port: globalThis.MessagePort) => Promise>' is not assignable to parameter of type 'DynamicOptions | Loader'.
然后尝试匹配类型enter image description here
但现在函数不可调用enter image description here
这个包使用了Blob,由于SSR的原因,它的show Blob没有定义,如何解决这个问题?
1条答案
按热度按时间hjqgdpho1#
我不是Next.js用户,但我猜
dynamic()
只适用于组件。但是
connect()
返回一个promise,这意味着您可以用普通的import()
替换静态导入。只要确保
connect()
不会在服务器上被调用。