【发布时间】:2019-08-01 05:47:28
【问题描述】:
我想实施评级星系统。单击后返回正确的星值。我在正确显示所选星星时遇到问题。就像在这张照片中一样,它没有向我显示黄色的 3 颗星。如何改变它? 组件:
export class RatingStarComponent implements OnInit {
stars: number[] = [1, 2, 3, 4, 5];
constructor() { }
ngOnInit() {
}
countStar(star) {
console.log('Value of star', star);
}
}
HTML:
<div class="row">
<div class="col-sm-12">
<ul class="list-inline rating-list" *ngFor="let star of stars" style="display: inline-block" >
<li (click)="countStar(star)"><i class="fa fa-star "></i></li>
</ul>
</div>
</div>
CSS:
.rating-list li {
float: right;
color: #ddd;
padding: 10px 5px;
}
.rating-list li:hover,
.rating-list li:hover ~ li {
color: #ffd700;
}
.rating-list {
display: inline-block;
list-style: none;
}
欢迎任何帮助或建议。
【问题讨论】: