umijs / umi

A framework in react community ✨
https://umijs.org
MIT License
15.39k stars 2.65k forks source link

UMI 开启SSR 使用‘braft-editor'组件,出现ReferenceError: document is not defined #3844

Closed 810106148 closed 4 years ago

810106148 commented 4 years ago

运行:npm start 出错: ReferenceError: document is not defined at D:\wwwroot\umi-server\examples\ant-motion\node_modules\braft-finder\dist\index.js:591:19 at D:\wwwroot\umi-server\examples\ant-motion\node_modules\braft-finder\dist\index.js:580:46 at module.exports (D:\wwwroot\umi-server\examples\ant-motion\node_modules\braft-finder\dist\index.js:645:88) at Object.defineProperty.value (D:\wwwroot\umi-server\examples\ant-motion\node_modules\braft-finder\dist\index.js:1095:37) at webpack_require (D:\wwwroot\umi-server\examples\ant-motion\node_modules\braft-finder\dist\index.js:30:30) at Object.defineProperty.value (D:\wwwroot\umi-server\examples\ant-motion\node_modules\braft-finder\dist\index.js:1116:1) at webpack_require (D:\wwwroot\umi-server\examples\ant-motion\node_modules\braft-finder\dist\index.js:30:30) at Object. (D:\wwwroot\umi-server\examples\ant-motion\node_modules\braft-finder\dist\index.js:2095:13) at __webpack_require__ (D:\wwwroot\umi-server\examples\ant-motion\node_modules\braft-finder\dist\index.js:30:30) at Object.defineProperty.value (D:\wwwroot\umi-server\examples\ant-motion\node_modules\braft-finder\dist\index.js:94:18) [nodemon] app crashed - waiting for file changes before starting...

ycjcl868 commented 4 years ago

braft-finder 不支持 SSR?

label-actions[bot] commented 4 years ago

@ycjcl868 请看下。

ycjcl868 commented 4 years ago

https://umijs.org/zh/guide/faq.html#ssr

810106148 commented 4 years ago

import BraftEditor from 'braft-editor' 只要引用,就出错。要怎么解决?

810106148 commented 4 years ago

https://umijs.org/zh/guide/faq.html#ssr 这里的方法 不能解决。我只引用,还没使用,都会出错。

zhangyuang commented 4 years ago

const braftFinder = typeof document !== 'undefined' ? require(''braft-editor') : {}