ElemeFE / element-react

Element UI
https://elemefe.github.io/element-react/index
MIT License
2.84k stars 441 forks source link

react 的升级版 next.js 上使用 element-ui 报错 #797

Open ripple666 opened 6 years ago

ripple666 commented 6 years ago

Description

引入模块的时候就开始报错: ReferenceError: window is not defined at D:\project\dapp\dpark-react\node_modules\element-react\dist\npm\es5\libs\utils\popper.js:57:16 at root (D:\project\dapp\dpark-react\node_modules\element-react\dist\npm\es5\libs\utils\popper.js:48:26) at Object.<anonymous> (D:\project\dapp\dpark-react\node_modules\element-react\dist\npm\es5\libs\utils\popper.js:53:3) at Module._compile (module.js:635:30) at Object.Module._extensions..js (module.js:646:10) at Module.load (module.js:554:32) at tryModuleLoad (module.js:497:12) at Function.Module._load (module.js:489:3) at Module.require (module.js:579:17) at require (internal/module.js:11:18) at Object.<anonymous> (D:\project\dapp\dpark-react\node_modules\element-react\dist\npm\es5\libs\utils\popper-mixins.js:18:15) at Module._compile (module.js:635:30) at Object.Module._extensions..js (module.js:646:10) at Module.load (module.js:554:32) at tryModuleLoad (module.js:497:12) at Function.Module._load (module.js:489:3)

Reproduce Steps

  1. [First Step]
  2. [Second Step]
  3. [and so on...]

Error Trace (if possible)

It's better to post up the error stack for us to trace this issue.

Solution

What needs to be done to address this issue? Ideally, provide a pull request with a fix.

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

PengyuanZhao commented 6 years ago

@ripple-xaz https://github.com/eleme/element-react/issues/516 似乎一直没有解决

fatlinesofcode commented 6 years ago

Seems to work ok if you wrap the element component in another component and then import it dynamically. e.g.

import dynamic from 'next/dynamic'
const MySelect = dynamic(import('../../components/ui/my-select/MySelect'))