gpt4 book ai didi

javascript - Angular2 错误 - 是否包含平台模块 (BrowserModule)?

转载 作者:数据小太阳 更新时间:2023-10-29 06:00:07 28 4
gpt4 key购买 nike

我只是想在 Angular2 中运行一个简单的 index.html 页面,但它在控制台中向我显示 zone.js 中的错误:

    Unhandled Promise rejection: No ErrorHandler. Is platform module (BrowserModule) included? ; Zone: <root> ; Task: Promise.then ; Value: Error: No ErrorHandler. Is platform module (BrowserModule) included?
at eval (application_ref.ts:364)
at ZoneDelegate.invoke (zone.js:391)
at Object.onInvoke (ng_zone.ts:296)
at ZoneDelegate.invoke (zone.js:390)
at Zone.run (zone.js:141)
at NgZone.run (ng_zone.ts:153)
at PlatformRef_._bootstrapModuleFactoryWithZone (application_ref.ts:359)
at eval (application_ref.ts:330)
at ZoneDelegate.invoke (zone.js:391)
at Zone.run (zone.js:141) Error: No ErrorHandler. Is platform module (BrowserModule) included?
at eval (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:4531:23)
at ZoneDelegate.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:391:26)
at Object.onInvoke (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:3922:33)
at ZoneDelegate.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:390:32)
at Zone.run (http://localhost:3000/node_modules/zone.js/dist/zone.js:141:43)
at NgZone.run (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:3853:69)
at PlatformRef_._bootstrapModuleFactoryWithZone (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:4526:23)
at eval (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:4568:59)
at ZoneDelegate.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:391:26)
at Zone.run (http://localhost:3000/node_modules/zone.js/dist/zone.js:141:43)

有人可以基本上帮助我了解它是什么以及如何解决这个问题。模块文件:

import {Component, NgModule} from "@angular/core";
import {App} from "./app";

@NgModule({
declarations: [App],
bootstrap: [App]
})
export class AppModule {

}

最佳答案

你错过了

import { BrowserModule } from '@angular/platform-browser';

添加到您的应用模块

@NgModule({
imports: [
BrowserModule,
]
...})

关于javascript - Angular2 错误 - 是否包含平台模块 (BrowserModule)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45256839/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com