【发布时间】:2021-05-19 18:03:39
【问题描述】:
我创建了一个 Angular 指令,如果满足某个条件,它会自动禁用按钮。
此外,如果用户将鼠标悬停在禁用按钮上,则应显示一个小工具提示。
为了实现这一点,我使用了 Angular 的 @HostListener 指令:
@HostListener("mouseenter")
show() {
this.tooltipService.showTooltip(this.tooltipRef, this.text);
setTimeout(() => this.tooltipService.hideTooltip(this.tooltipRef), 2000);
}
这在 Firefox 上运行良好,但在 Chrome 上,当按钮被禁用时不会引发 mouseenter 事件。
我对这种不一致感到非常困惑,我找不到任何有关此问题的文档。
有什么方法我仍然可以访问 Chrome 上的 mouseenter 事件?
【问题讨论】:
-
但是如果你确实想要一个解决方法 - 将按钮包装在一个 div 中并将工具提示移动到父组件
-
@SalminSkenderovic 知道为什么 Firefox 的行为与 Chrome 不同吗?
标签: angular google-chrome firefox mouseenter disabled-input