我正在开发角度应用程序,
我在其中生成了一个称为'flow-breadcrumb'的组件的地方
flow-breadcrumb.html
<ul class="bv-flow-bar">
<li *ngFor="let item of steps; let i = index;" [ngClass]="getActiveClass(item)" [style.width.%]="100/stepCount">
<span>{{item}}</span>
</li>
</ul>
flow-breadcrumb.scss
flow-breadcrumb {
.bv-flow-bar {
padding-left: 0 !important;
li {
list-style-type: none;
float: left;
position: relative;
text-align: center;
span {
width: 2.5rem;
height: 2.5rem;
line-height: 2rem;
border: 2px solid map-get($colors, primary);
color: map-get($colors, primary);
display: block;
text-align: center;
margin: 0 auto;
border-radius: 15px;
background-color: map-get($colors, white);
font-weight: bold;
}
&:after {
content: "";
position: absolute;
width: 100%;
height: 2px;
background-color: map-get($colors, primary);
top: 1.2rem;
left: -50%;
z-index: -1;
}
&.bv-flow-active {
color: map-get($colors, primary);
span {
border-color: map-get($colors, primary);
color: map-get($colors, primary);
}
&:after {
background-color: map-get($colors, primary);
}
&~li {
span {
border-color: map-get($colors, lightgray);
border-width: 2px;
color: map-get($colors, lightgray);
font-weight: normal;
}
&:after {
background-color: map-get($colors, lightgray);
}
}
}
&:first-child:after {
content: none;
}
}
&:after {
content: '';
display: block;
clear: both;
}
}
}
flow-breadcrumb.ts
export class FlowBreadcrumbComponent implements OnInit {
@Input()
public stepCount: number = 0;
@Input()
public step: number = 0;
public steps: Array<number> = [];
public getActiveClass(index: number): string {
if (this.step == index) {
return 'bv-flow-active';
} else {
return '';
}
}
public ngOnInit(): void {
for (let n = 1; n <= this.stepCount; n++) {
this.steps.push(n);
}
}
以及components.module.ts
@NgModule({
declarations: [
FlowBreadcrumbComponent
],
imports: [],
exports: [
FlowBreadcrumbComponent
]
})
export class ComponentsModule { }
我只写了上面的那些代码,当我尝试运行该应用程序时,它向我显示错误:
Template parse errors: Can't bind to 'ngClass' since it isn't a known property of 'li'. ("<ul class="bv-flow-bar">
<li *ngFor="let item of steps; let i = index;" [ERROR ->][ngClass]="getActiveClass(item)" [style.width.%]="100/stepCount">
<span>{{item}}</span>
我在哪里犯错?请帮助我找到..
您缺少IonicModule
Imports数组上的components.module.ts
导入。