我已经为这个问题苦苦挣扎了几个小时,而且变得非常令人沮丧。我有一个子组件,我需要在其中检测鼠标何时悬停在某物上。mouseenter 事件正确触发,并且我在子组件(app-circle)中的方法被触发,但是在我发出()之后,父组件的方法不会被调用。
角度版本:8.0.1
以下是一些相关代码:
子组件(app-circle):
TS:
@Output() mouseEnter: EventEmitter<any> = new EventEmitter();
...
public onMouseEnter() {
this.mouseEnter.emit();
}
HTML:
<a (mouseenter)="onMouseEnter()"> ... </a>
父组件:
HTML:
<app-circle (mouseEnter)="onBackgroundCircleMouseEnter()"> </app-circle>
TS:
public onBackgroundCircleMouseEnter() {
console.log('emitted');
}