【问题标题】:ASP.NET CORE 2 + ANGULAR 4: NodeInvocationException: Prerendering failed because of error: ReferenceError: window is not definedASP.NET CORE 2 + ANGULAR 4:NodeInvocationException:预渲染因错误而失败:ReferenceError:未定义窗口
【发布时间】:2018-03-23 12:48:31
【问题描述】:

我正在尝试使用 ngx-chips 进行标签输入,但在导入 BrowserAnimationsModule 时遇到了这个问题。

在导入 BrowserAnimationsModule 时,我收到以下错误:

An unhandled exception occurred while processing the request.

NodeInvocationException: document is not defined
ReferenceError: document is not defined

一旦我在 app.module.shared.ts 下的 import 中评论 BrowserAnimationsModule,我的应用程序可以正常工作,但一旦我取消评论它,我就会遇到同样的错误。

请问我该如何丢弃这个,我已经为此工作了超过 4 天。 或建议任何其他 Angular 4 标签输入库 我正在使用 ASP.NET Core 2 SPA 模板。

谢谢...

【问题讨论】:

    标签: asp.net angular web asp.net-core-2.0


    【解决方案1】:

    在您视图的 (Index.cshtml) 应用标记中,将 asp-prerender-module 替换为 asp-ng2-prerender-module

    【讨论】:

    • 谢谢,这用 ASP.NET Core 2 和 SPA 模板为我解决了这个问题。
    • asp-ng2-prerender-module 是新关键字还是您的“解决方案”只是禁用 SSR?
    • 如果您的组件(在我的例子中是 Kendo UI)正在寻找“窗口”,那么它们与 SSR 不兼容。服务器上没有“窗口”或任何其他 DOM 元素,对吧?因此,我的“解决方案”是克服这个绊脚石并继续前进。 . .到下一个绊脚石。
    猜你喜欢
    • 1970-01-01
    • 2017-10-23
    • 1970-01-01
    • 2017-05-08
    • 2017-09-12
    • 2020-11-12
    • 1970-01-01
    • 2017-06-18
    • 2021-10-08
    相关资源
    最近更新 更多