从'react'中导入React,{组件,惰性,暂挂};
//从'./Components/myComp'导入MyComp;
const MyComp = lazy(()=> import('./ components / myComp'));
500内部服务器错误 加载“〜/ Content / Scripts / dist / server.js”时出错:ReferenceError:在匿名函数中未定义“窗口”(server.js:1:1832)->…op =“”,o.oe = function (e){throw console.error(e),e}; var a = window.webpackJsonp = window.webpackJsonp || [],…在全局代码(server.js:1:1)
答案 0 :(得分:0)
您必须使用可加载的https://github.com/gregberge/loadable-components而不是React.lazy。当您进行服务器端渲染时,React.lazy无法正常工作。
import loadable from '@loadable/component'
// This dynamic import will not be processed server-side
const Other = loadable(() => import('./Other'), { ssr: false })