【发布时间】:2017-11-07 09:44:04
【问题描述】:
我正在开发 Angular 4 框架。我想在我的应用主页上添加一个材质进度条。我遵循了 Angular Material 环境设置的官方指南。
之后,我在 .html 文件中添加了进度条的代码并编译。它没有在网页上更新。我该如何解决这个问题?
HTML代码是:
<mat-card>
<mat-card-content>
<h2 class="example-h2">Progress bar configuration</h2>
<section class="example-section">
<label class="example-margin">Color:</label>
<mat-radio-group [(ngModel)]="color">
<mat-radio-button class="example-margin" value="primary">
Primary
</mat-radio-button>
<mat-radio-button class="example-margin" value="accent">
Accent
</mat-radio-button>
<mat-radio-button class="example-margin" value="warn">
Warn
</mat-radio-button>
</mat-radio-group>
</section>
<section class="example-section">
<label class="example-margin">Mode:</label>
<mat-radio-group [(ngModel)]="mode">
<mat-radio-button class="example-margin" value="determinate">
Determinate
</mat-radio-button>
<mat-radio-button class="example-margin" value="indeterminate">
Indeterminate
</mat-radio-button>
<mat-radio-button class="example-margin" value="buffer">
Buffer
</mat-radio-button>
<mat-radio-button class="example-margin" value="query">
Query
</mat-radio-button>
</mat-radio-group>
</section>
<section class="example-section" *ngIf="mode == 'determinate' || mode == 'buffer'">
<label class="example-margin">Progress:</label>
<mat-slider class="example-margin" [(ngModel)]="value"></mat-slider>
</section>
<section class="example-section" *ngIf="mode == 'buffer'">
<label class="example-margin">Buffer:</label>
<mat-slider class="example-margin" [(ngModel)]="bufferValue"></mat-slider>
</section>
</mat-card-content>
</mat-card>
<mat-card>
<mat-card-content>
<h2 class="example-h2">Result</h2>
<section class="example-section">
<mat-progress-bar
class="example-margin"
[color]="color"
[mode]="mode"
[value]="value"
[bufferValue]="bufferValue">
</mat-progress-bar>
</section>
</mat-card-content>
</mat-card>
而对应的component.ts文件代码为
@NgModule({
imports: [MatButtonModule, MatCheckboxModule],
})
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss']
})
export class HomeComponent {
color = 'primary';
mode = 'determinate';
value = 50;
bufferValue = 75;
}
【问题讨论】:
-
控制台有输出吗?你能给我们你的材料版本吗?他们的组件的前缀发生了一些变化。
-
仪表板中没有输出。什么都不可见。
-
@angular/material": "^2.0.0-beta.12
-
其他一些材质组件,如单选按钮、复选框等作为输出可见。但进度条不可见。
-
在浏览器中检查
inspector。 (例如在 DevTools 中的chrome中有标签elements)如果在 html 文件中生成 mat-progress-bar,还要检查我的答案,可能导入有问题。
标签: html angular typescript progress-bar angular-material