gpt4 book ai didi

angular - 模块 'undefined' 声明的意外值 'AppModule'

转载 作者:太空狗 更新时间:2023-10-29 16:46:06 24 4
gpt4 key购买 nike

这里有什么问题?我试图让它工作,但我在标题中收到该错误。我已经包含了 <router-outlet></router-outlet>app.component.html那就是templateUrlapp.component.ts 调用, 仍然没有运气。

app.module.ts:

import { NgModule }             from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { RouterModule, Routes } from '@angular/router';


import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { TopnavComponent } from './components/navbars/topnav/topnav.component';
import { LeftnavComponent } from './components/navbars/leftnav/leftnav.component';
import { LeftnavsecondaryComponent } from './components/navbars/leftnav-secondary/leftnav-secondary.component';
import { WorldofwarcraftComponent } from './components/games/worldofwarcraft/worldofwarcraft.component';

@NgModule({
imports: [ BrowserModule, FormsModule, AppRoutingModule ],
declarations: [ AppComponent, TopnavComponent, LeftnavComponent, LeftnavsecondaryComponent, WorldofwarcraftComponent ],
bootstrap: [ AppComponent ]
})

export class AppModule { }

app-routing.module.ts:

import { NgModule }              from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { WorldofwarcraftComponent } from './components/games/worldofwarcraft/worldofwarcraft.component';

const appRoutes: Routes = [
{ path: 'worldofwacraft', component: WorldofwarcraftComponent }
];

@NgModule({
imports: [ RouterModule.forRoot(appRoutes) ],
exports: [ RouterModule ]
})

export class AppRoutingModule {}

最佳答案

我遇到了同样的错误,有时会出现这个问题,您只需要使用 ng serve 或您使用的任何 CLI 重新运行服务器,如前所述 here

关于angular - 模块 'undefined' 声明的意外值 'AppModule',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41560510/

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