我购买了一个在 HTML + CSS 简单项目方法上运行良好的主题,但我想将其转换为 Angular 6 项目。
我设法让主题在 Angular 6 上正常工作,但是在 Angular 6 应用程序中查看我的代码时,我得到了一个奇怪的 CSS 行为:
<!-- begin:: Page -->
<div class="m-grid m-grid--hor m-grid--root m-page">
<m-header *ngIf="showContent"></m-header>
<!-- begin::Body -->
<div class="m-grid__item m-grid__item--fluid m-grid m-grid--ver-desktop m-grid--desktop m-body">
<m-leftmenu></m-leftmenu>
<div *ngIf="showContent" #mContentWrapper>
<router-outlet></router-outlet>
</div>
</div>
<m-footer></m-footer>
</div>
<!-- end:: Page -->
<!-- begin::Scroll Top -->
<div id="m_scroll_top" class="m-scroll-top">
<i class="la la-arrow-up"></i>
</div>
<!-- end::Scroll Top -->
这是我的 PainelComponent ( painel.component.html ) 中的代码,我使用带有延迟加载的 a 将我的 HomeComponent 加载到 PainelComponent 中,这是来自 HomeComponent 的代码:
<div class="m-grid__item m-grid__item--fluid m-wrapper">
<!-- BEGIN: Subheader -->
<div class="m-subheader ">
<div class="d-flex align-items-center">
<div class="mr-auto">
<h3 class="m-subheader__title ">Painel</h3>
</div>
<div>
<span class="m-subheader__daterange" id="m_dashboard_daterangepicker">
<span class="m-subheader__daterange-label">
<span class="m-subheader__daterange-title"></span>
<span class="m-subheader__daterange-date m--font-brand"></span>
</span>
<a href="#" class="btn btn-sm btn-brand m-btn m-btn--icon m-btn--icon-only m-btn--custom m-btn--pill">
<i class="la la-angle-down"></i>
</a>
</span>
</div>
</div>
</div>
<!-- END: Subheader -->
<div class="m-content">
<!--Begin::Section-->
<div class="row">
<div class="col-xl-12">
</div>
<div class="col-xl-12 col-lg-12">
<!--begin:: Widgets/Quick Stats-->
<div class="row m-row--full-height">
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="m-portlet m-portlet--half-height m-portlet--border-bottom-brand ">
<div class="m-portlet__body">
<div class="m-widget26">
<div class="m-widget26__number">
570
<small>All Sales</small>
</div>
<div class="m-widget26__chart" style="height:90px; width: 220px;">
<canvas id="m_chart_quick_stats_1"></canvas>
</div>
</div>
</div>
</div>
<div class="m--space-30"></div>
<div class="m-portlet m-portlet--half-height m-portlet--border-bottom-danger ">
<div class="m-portlet__body">
<div class="m-widget26">
<div class="m-widget26__number">
690
<small>All Orders</small>
</div>
<div class="m-widget26__chart" style="height:90px; width: 220px;">
<canvas id="m_chart_quick_stats_2"></canvas>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="m-portlet m-portlet--half-height m-portlet--border-bottom-success ">
<div class="m-portlet__body">
<div class="m-widget26">
<div class="m-widget26__number">
230
<small>All Transactions</small>
</div>
<div class="m-widget26__chart" style="height:90px; width: 220px;">
<canvas id="m_chart_quick_stats_3"></canvas>
</div>
</div>
</div>
</div>
<div class="m--space-30"></div>
<div class="m-portlet m-portlet--half-height m-portlet--border-bottom-accent ">
<div class="m-portlet__body">
<div class="m-widget26">
<div class="m-widget26__number">
470
<small>All Comissions</small>
</div>
<div class="m-widget26__chart" style="height:90px; width: 220px;">
<canvas id="m_chart_quick_stats_4"></canvas>
</div>
</div>
</div>
</div>
</div>
</div>
<!--end:: Widgets/Quick Stats-->
</div>
</div>
<!--End::Section-->
</div>
</div>
这是我不想要的方法(这是 ANGULAR 6 WITH ):
但是当我从 HomeComponent 中选择所有代码时,从 PainelComponent 中删除这一行:
<div *ngIf="showContent" #mContentWrapper>
<router-outlet></router-outlet>
</div>
并将 HomeComponent 中的所有代码放入 100% 的全宽包装器中,它的工作原理与我预期的一样,为什么会这样?我必须使用路由器做什么,我在想 Angular 只是从一个组件中添加 HTML 文件,但我想不是这样的。
这是我将 home.component.html 放入 painel.component.html 时的代码
<!-- begin:: Page -->
<div class="m-grid m-grid--hor m-grid--root m-page">
<m-header *ngIf="showContent"></m-header>
<!-- begin::Body -->
<div class="m-grid__item m-grid__item--fluid m-grid m-grid--ver-desktop m-grid--desktop m-body">
<m-leftmenu></m-leftmenu>
<div class="m-grid__item m-grid__item--fluid m-wrapper">
<!-- BEGIN: Subheader -->
<div class="m-subheader ">
<div class="d-flex align-items-center">
<div class="mr-auto">
<h3 class="m-subheader__title ">Painel</h3>
</div>
<div>
<span class="m-subheader__daterange" id="m_dashboard_daterangepicker">
<span class="m-subheader__daterange-label">
<span class="m-subheader__daterange-title"></span>
<span class="m-subheader__daterange-date m--font-brand"></span>
</span>
<a href="#" class="btn btn-sm btn-brand m-btn m-btn--icon m-btn--icon-only m-btn--custom m-btn--pill">
<i class="la la-angle-down"></i>
</a>
</span>
</div>
</div>
</div>
<!-- END: Subheader -->
<div class="m-content">
<!--Begin::Section-->
<div class="row">
<div class="col-xl-12">
</div>
<div class="col-xl-12 col-lg-12">
<!--begin:: Widgets/Quick Stats-->
<div class="row m-row--full-height">
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="m-portlet m-portlet--half-height m-portlet--border-bottom-brand ">
<div class="m-portlet__body">
<div class="m-widget26">
<div class="m-widget26__number">
570
<small>All Sales</small>
</div>
<div class="m-widget26__chart" style="height:90px; width: 220px;">
<canvas id="m_chart_quick_stats_1"></canvas>
</div>
</div>
</div>
</div>
<div class="m--space-30"></div>
<div class="m-portlet m-portlet--half-height m-portlet--border-bottom-danger ">
<div class="m-portlet__body">
<div class="m-widget26">
<div class="m-widget26__number">
690
<small>All Orders</small>
</div>
<div class="m-widget26__chart" style="height:90px; width: 220px;">
<canvas id="m_chart_quick_stats_2"></canvas>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="m-portlet m-portlet--half-height m-portlet--border-bottom-success ">
<div class="m-portlet__body">
<div class="m-widget26">
<div class="m-widget26__number">
230
<small>All Transactions</small>
</div>
<div class="m-widget26__chart" style="height:90px; width: 220px;">
<canvas id="m_chart_quick_stats_3"></canvas>
</div>
</div>
</div>
</div>
<div class="m--space-30"></div>
<div class="m-portlet m-portlet--half-height m-portlet--border-bottom-accent ">
<div class="m-portlet__body">
<div class="m-widget26">
<div class="m-widget26__number">
470
<small>All Comissions</small>
</div>
<div class="m-widget26__chart" style="height:90px; width: 220px;">
<canvas id="m_chart_quick_stats_4"></canvas>
</div>
</div>
</div>
</div>
</div>
</div>
<!--end:: Widgets/Quick Stats-->
</div>
</div>
<!--End::Section-->
</div>
</div>
</div>
<m-footer></m-footer>
</div>
<!-- end:: Page -->
<!-- begin::Scroll Top -->
<div id="m_scroll_top" class="m-scroll-top">
<i class="la la-arrow-up"></i>
</div>
<!-- end::Scroll Top -->
这是我想要的方法: