我有一个angular 6通用应用程序,我正在为图像滑块集成ng-simple-slideshow,它构建成功,但在运行时:npm运行服务:SSR给出以下错误:请提出一些解决办法。谢谢
ReferenceError: window is not defined
at F:\new_trd_back_up\dist\server.js:247023:8032
at vt (F:\new_trd_back_up\dist\server.js:246852:163)
at Object.module.exports (F:\new_trd_back_up\dist\server.js:246852:177)
at __webpack_require__ (F:\new_trd_back_up\dist\server.js:20:30)
at Object.jspdf (F:\new_trd_back_up\dist\server.js:87271:18)
at __webpack_require__ (F:\new_trd_back_up\dist\server.js:59361:30)
at Object../src/app/presentation/presentation.component.ts (F:\new_trd_back_up\dist\server.js:81159:13)
at __webpack_require__ (F:\new_trd_back_up\dist\server.js:59361:30)
at Object../src/app/presentation/presentation.component.ngfactory.js (F:\new_trd_back_up\dist\server.js:81046:11)
at __webpack_require__ (F:\new_trd_back_up\dist\server.js:59361:30)
3条答案
按热度按时间a64a0gku1#
"未定义窗口"来自访问窗口变量的第三方库。
您应该使用浏览器检查条件 Package 代码
here是一个很好的用法示例。
z5btuh9x2#
使用NestJS,只需应用
applyDomino
即可,如下所示:**编辑:**从
Angular 8
升级到Angular 10
后就停止工作了,这可以在#451的基础上实现,到目前为止,原始的domino
必须以这样的形式使用(server.ts
):更详细的答案#830(评论)。
mspsb9vt3#
编辑:这个答案和问题是错误的,从根,Angular 使用Domino这些天无论如何,你应该使用注入或警卫,为进一步解释,阅读手册。
这也可以通过使用多米诺骨牌来解决。
将此添加到“server.ts”:
Github的票务问题及建议