.net Core 2 Angle 5 Prerender失败

时间:2018-06-21 07:55:53

标签: node.js angular asp.net-core asp.net-core-2.0

我遇到以下错误:

  

NodeInvocationException:由于错误而导致预呈现失败:ReferenceError:未定义窗口

我已经阅读了Microsoft本身提供的以下文档: https://docs.microsoft.com/nl-nl/aspnet/core/client-side/spa/angular?view=aspnetcore-2.0&tabs=visual-studio

因此预渲染被触发了,但是失败了,因为在服务器端当然不存在窗口。

现在,我已经看到了Angular 4随附的Visual Studio中较旧的angular模板的修复程序。文档中的一个模板具有Angular 5,并且版本有所不同。因此,我找到了修复程序,但由于我没有index.cshtml,因此无法使用。在新模板中,您将获得一个普通的index.html:

    <!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Test/title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <script src="https://use.fontawesome.com/93acba991a.js"></script>

</head>
<body>
  <app-root>Loading...</app-root>
</body>
</html>

第一个项目的解决方案是:

  

将“ asp-prerender-module”替换为“ asp-ng2-prerender-module”

如您所见,我那里没有asp-prerender-module,将其更改为“ asp-ng2-prerender-module”对我不起作用。我正在使用@ agm / core软件包,它给了我这个错误,但是我听到多个软件包都遇到了这个问题。我希望有人能解决此问题。

0 个答案:

没有答案