在Angular v9中,@Output发射器未被父组件接收的问题可能是由于以下原因导致的:
例子:
// 子组件
@Component({
selector: 'app-child',
template: `
`
})
export class ChildComponent {
@Output() eventEmitter = new EventEmitter();
emitEvent() {
this.eventEmitter.emit();
}
}
// 父组件模板
例子:
// 父组件
export class ParentComponent {
handleEvent() {
console.log('事件已被接收');
}
}
例子:
请注意,以上示例中的代码仅用于演示目的,实际中的代码可能会有所不同。确保在实际应用中正确使用和配置@Output发射器和父子组件通信。