您可以使用
(document:click)事件:
@Component({ host: { '(document:click)': 'onClick($event)', },})class SomeComponent() { constructor(private _eref: ElementRef) { } onClick(event) { if (!this._eref.nativeElement.contains(event.target)) // or some similar check doSomething(); }}


