小编Sus*_*shi的帖子

由于NgZone引用错误,预渲染失败

我在实施NgZones方面遇到了麻烦.即使我已经定义了NgZone,我也会收到此错误."NodeInvocationException:由于错误导致预渲染失败:ReferenceError:未定义NgZone"

这是我的app.error-handle.ts文件,我使用的是NgZone.

   import { ToastyService } from 'ng2-toasty';
import { ErrorHandler, Inject, NgZone } from '@angular/core';

export class AppErrorHandler implements ErrorHandler {
  constructor(
    private ngZone: NgZone,
    @Inject(ToastyService) private toastyService: ToastyService) {
  }

  handleError(error: any): void {
    this.ngZone.run(() => {
      this.toastyService.error({
        title: 'Error',
        msg: 'An unexpected error happened.',
        theme: 'bootstrap',
        showClose: true,
        timeout: 5000
      });
    });

  }
}
Run Code Online (Sandbox Code Playgroud)

这是我的webpack.config.vendor.js文件.

const path = require('path');
    const webpack = require('webpack');
    const ExtractTextPlugin = require('extract-text-webpack-plugin');
    const merge = require('webpack-merge');
    const treeShakableModules = [
        '@angular/animations',
        '@angular/common', …
Run Code Online (Sandbox Code Playgroud)

typescript visual-studio-code angular2-services angular2-zone asp.net-core-2.0

4
推荐指数
1
解决办法
1587
查看次数