每当我从 @ angular / platform-browser / animations 中包含 BrowserAnimationsModuel 时,我都会收到以下未处理的异常库进入根模块。我正在使用Angular 4和Microsoft SPA服务(JavaScript服务)。 这似乎与index.cshtml文件中的 asp-prerender-module 指令直接冲突。
<app asp-prerender-module="ClientApp/dist/main-server" asp-prerender-data="Options.Value">Loading...</app>
这是根模块代码(对于客户端):
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { BntButtonModule } from '@bentley/angular-components';
import { sharedConfig } from './app.module.shared';
import { CLIENT_CONFIGURATION } from "./client-configuration";
import { AuthService } from './services/auth.service';
import { AuthServiceClient } from './services/auth.service.client';
@NgModule({
bootstrap: sharedConfig.bootstrap,
declarations: [
...sharedConfig.declarations
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
BntButtonModule,
BrowserAnimationsModule,
...sharedConfig.imports
],
providers: [
...sharedConfig.providers,
{ provide: AuthService, useClass: AuthServiceClient },
{ provide: 'ORIGIN_URL', useValue: location.origin },
{ provide: CLIENT_CONFIGURATION, useValue: (<any>window).clientAuth }
]
})
export class AppModule {
}
以下是例外:
An unhandled exception occurred while processing the request.
WinHttpException: The connection with the server was terminated abnormally
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
HttpRequestException: An error occurred while sending the request.
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
Stack Query Cookies Headers
WinHttpException: The connection with the server was terminated abnormally
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
System.Net.Http.WinHttpHandler+<StartRequest>d__103.MoveNext()
当我在客户端和服务器根模块中导入BrowserAnimationsModule时,我也看到以下异常:
Exception: Call to Node module failed with error: ReferenceError: document is not defined
at DefaultDomRenderer2.module.exports.DefaultDomRenderer2.selectRootElement (D:\gitrepo\auth\src\Bentley.Api.Management.Angular\ClientApp\dist\vendor.js:47809:72)
at BaseAnimationRenderer.selectRootElement (D:\gitrepo\auth\src\Bentley.Api.Management.Angular\ClientApp\dist\main-server.js:10852:106)
at createElement (D:\gitrepo\auth\src\Bentley.Api.Management.Angular\ClientApp\dist\vendor.js:9483:23)
at createViewNodes (D:\gitrepo\auth\src\Bentley.Api.Management.Angular\ClientApp\dist\vendor.js:12449:44)
at createRootView (D:\gitrepo\auth\src\Bentley.Api.Management.Angular\ClientApp\dist\vendor.js:12378:5)
at Object.createProdRootView [as createRootView] (D:\gitrepo\auth\src\Bentley.Api.Management.Angular\ClientApp\dist\vendor.js:13061:12)
at ComponentFactory_.module.exports.ComponentFactory_.create (D:\gitrepo\auth\src\Bentley.Api.Management.Angular\ClientApp\dist\vendor.js:10169:46)
at ComponentFactoryBoundToModule.module.exports.ComponentFactoryBoundToModule.create (D:\gitrepo\auth\src\Bentley.Api.Management.Angular\ClientApp\dist\vendor.js:3586:29)
at ApplicationRef_.module.exports.ApplicationRef_.bootstrap (D:\gitrepo\auth\src\Bentley.Api.Management.Angular\ClientApp\dist\vendor.js:5075:57)
at D:\gitrepo\auth\src\Bentley.Api.Management.Angular\ClientApp\dist\vendor.js:4858:81