alibaba / ChatUI

The UI design language and React library for Conversational UI
https://chatui.io
MIT License
2.61k stars 277 forks source link

服务端渲染报错 `window is not defined`, #113

Open qianxuemin opened 1 year ago

qianxuemin commented 1 year ago

服务端渲染时报错:

版本:@chatui/core@2.4.2

报错信息: ReferenceError: window is not defined

报错文件:

node_modules/@chatui/core/lib/utils/canUse.js:30:30

  26 |   smoothScroll: function smoothScroll() {
  27 |     return 'scrollBehavior' in document.documentElement.style;
  28 |   },
  29 |   touch: function touch() {
> 30 |     return 'ontouchstart' in window;
     |                              ^
  31 |   }
  32 | };
  33 | 
frey0415 commented 1 year ago

import dynamic from 'next/dynamic'; const Chat = dynamic(() => import('@/components/ChatUI'), {ssr: false});