【发布时间】:2017-12-05 15:34:30
【问题描述】:
我无法在带有 VS 2017 社区的 Angular 2 SPA 模板上显示加载屏幕。
我的 index.cshtml 中有以下内容。
<app asp-prerender-module="ClientApp/dist/main-server">
<h1>APP IS LOADING</h1>
<div class="loader"></div>
</app>
.loader 的类(在我的 app.component.css 文件中)
.loader {
border: 16px solid #f3f3f3; /* Light grey */
border-top: 16px solid #3498db; /* Blue */
border-radius: 50%;
width: 120px;
height: 120px;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
我的 app.component.html 是;
<nav-menu></nav-menu>
<hero></hero>
<div class='container-fluid'>
<div class='row'>
<div class='col-sm-12 body-content'>
<router-outlet></router-outlet>
</div>
</div>
</div>
<footer></footer>
我的 app.component.ts 在哪里;
import { Component } from '@angular/core';
@Component({
selector: 'app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
}
但是,当我加载页面时,页面正在加载并且文本图像似乎正在动态加载(我也在发布到我的服务器后对此进行了测试,并添加了一个大背景图像进行测试,它显示为灰色框直到图像慢慢加载)。
我错过了什么吗?
【问题讨论】:
-
我猜app组件使用封装模式
Emulated。在这种情况下,您必须使用 ::ng-deep > .loader -
我明白你的意思,但这并不能解释为什么 h1 至少没有出现?即在加载所有角度视图之前,它的显示似乎没有显示节点内的 html?
-
如果你的 AppComponent 模板不包含
标签,那么 h1 和 div 就没有可以渲染的地方。它们将被忽略。 -
嗯,我更新了问题以包含我的 app.component 文件,这样你就可以看到我的路由器插座,这有帮助吗?
标签: javascript css angular