簡體   English   中英

Angular,為什么我的組件沒有渲染?

[英]Angular, why isn't my component rendering?

按照在線代碼完成 Angular noob。 我的登錄頁面在路徑“”上呈現,但停止了,我不知道為什么。

login.component.html

<form (submit)="loginUser($event)">
    <div class="container">
    <div>
      <input type="text" autocomplete="off" placeholder="Email" id="emailAddress">
    </div>
    <div>
      <input type="password" autocomplete="off" placeholder="Password" id="password">
    </div>
    <div>
      <button type="submit" id="submit">Submit</button>
    </div>
  </div>
  </form>

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { LoginComponent } from './login/login.component';

@NgModule({
  declarations: [
    AppComponent,
    LoginComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    RouterModule.forRoot([
      {path: '',
      component: LoginComponent}
    ])
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

app.component.html

<router-outlet></router-outlet>

確保在 index.html 文件的<head>中有<base href="/">

https://angular.io/guide/router#base-href

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM