页面使用角度路由器在浏览器中显示两次? [英] page is showing twice in the browser using angular router?
问题描述
Angular 在默认端口 localhost:4200
上加载页面在浏览器中,知道这里实现了什么错误吗?
app-routing.module.ts
import { NgModule } from '@angular/core';从'@angular/router' 导入 { Routes, RouterModule };从 './app.component' 导入 { AppComponent };const 路由:路由 = [{路径:'专业问题',组件:AppComponent},{小路: '',重定向到:'专业问题',路径匹配:'完整'}];@NgModule({进口:[RouterModule.forRoot(routes)],出口:[路由器模块]})导出类 AppRoutingModule { }
app.component.html
解决方案 Remove Router-Outlet因为当您最后添加该标签时,它会再次运行该部分.所以从最后删除那部分并检查
<div class="container-fluid"><div class="row"><div class="col-sm-5"><app-create-questions></app-create-questions>
<div class="col-sm-1"><div class="row"><button type="button" class="btn btn-primary" data-backdrop='static' (click)="openModal()" style="margin-top: 300px;"data-toggle="modal" data-target="#exampleModalLong">开始格式化</button>
<div class="col-sm-5"><app-format-questions></app-format-questions>