简化代码后,代码没有报错,但是ngOnChanges不起作用
来源:6-11 本章实战
qq_sumillie_0
2017-09-29
@Input()
rating:number =0;
stars:boolean [];
@Input()
isStar:boolean=true;
@Output()
starInfo:EventEmitter<number>=new EventEmitter();
constructor() { }
ngOnInit() {
}
ngOnChanges(changes: SimpleChanges): void {
this.stars=[];
for(let i=1; i<=5; i++){
this.stars.push(i>this.rating);
}
}
starClick(index:number){
if(!this.isStar){
this.rating=index+1;
this.starInfo.emit(this.rating);
}
}
星星点击事件也不起作用了
点击保存按钮后console显示Form submission canceled because the form is not connected写回答
2回答
-
胖虎啊咔咔咔
2018-04-02
我也提示这个问题,但是还是可以点击,对效果没有影响
00 -
JoJo
2017-10-06
恢复到简化前没问题的状态。一点一点改,看看哪一步导致出问题的。
00
相似问题