antd ToolTip Popover 气泡组件偏移闪烁问题

1,213 阅读1分钟

现象:

在鼠标 hover父元素上时,会将子元素的icon展示出来,再次 hover 子元素icon可以正常展示气泡中的内容,但是当 取消hover 时会出现偏移闪烁,即在气泡内容会在 body 上展示,然后消失,类似下图:

<a-popover placement="bottom" :get-popup-container="trigger=>trigger.parentElement" arrow-point-at-center :mouse-enter-delay="0.1" @click.stop>
  <div class="contact-tip" slot="content">
    <span>添加到首页-我的应用</span>
  </div>
  <app-icon v-else type="shoucangc" class="shoucang" @click.native.prevent.stop="operateFavorite(classify,'classify')"></app-icon>
</a-popover>

image.png

解决方案

添加属性 mouseLeaveDelay 属性 :mouse-leave-delay="0" 就是在鼠标移出之后立即关闭,这样气泡内容就不会因为找不到原有的父元素,而去找最外层公共的父亲了

<a-popover placement="bottom" :get-popup-container="trigger=>trigger.parentElement" arrow-point-at-center :mouse-enter-delay="0.1" @click.stop :mouse-leave-delay="0">
  <div class="contact-tip" slot="content">
    <span>添加到首页-我的应用</span>
  </div>
  <app-icon v-else type="shoucangc" class="shoucang" @click.native.prevent.stop="operateFavorite(classify,'classify')"></app-icon>
</a-popover>

因为临近发版,这也是我能找到的唯一方法了,如果有其他更好的方法,可以评论,大家共同进步!!!