我想获得这个在Angular4组件,而不使用jQuery.
我需要根据鼠标方向显示带有动画的叠加div,包括mouseover和mouseout.我试图重写我的组件中的示例代码,但我无法获得event.target的宽度和高度.
我的div:
<div (mouseover)='showOverlay($event)'>div to hover</div>
Run Code Online (Sandbox Code Playgroud)
零件:
export class MyComponent implements OnInit {
constructor(private _el: ElementRef) {
}
ngOnInit() {
}
showOverlay(e) {
const target = e.target;
console.log(target._el.nativeElement); // Returns undefined
console.log(target.nativeElement); // Returns undefined
console.log(target.nativeElement.width); // Error
console.log(target._el.nativeElement.width); // Error
}
}
Run Code Online (Sandbox Code Playgroud)
任何的想法?
谢谢
angular ×1