Skip to content

Popover 气泡提示

介绍

默认通过 v-model 或实例方法控制显示;也可改为点击、长按触发。

基础用法

不传 trigger 时通过 v-model 或实例方法控制显示。

html
<vd-popover v-model="show" message="提示消息内容">
  <vd-button @click.stop="show = !show">
    {{ show ? '关闭' : '打开' }}
  </vd-button>
</vd-popover>
ts
const show = ref(false);

点击触发

trigger 设置为 click,点击触发容器时切换显示。

html
<vd-popover trigger="click" message="提示消息内容">
  <vd-button>点击展示</vd-button>
</vd-popover>

浅色风格

通过 theme 设置主题风格,默认为 dark

html
<vd-popover trigger="click" theme="light" message="浅色主题提示">
  <vd-button>light</vd-button>
</vd-popover>

长按触发

trigger 设置为 longpress,可改为长按触发。

html
<vd-popover trigger="longpress" message="长按展示提示">
  <vd-button>长按展示</vd-button>
</vd-popover>

弹出位置

通过 position 设置弹出位置。

html
<vd-popover trigger="click" position="top" message="提示消息内容">
  <vd-button>top</vd-button>
</vd-popover>

API

Props

参数说明类型默认值
v-model是否展示boolean-
message提示信息string-
trigger触发方式,不传时手动控制'click' | 'longpress'-
position弹出位置top top-start top-end bottom bottom-start bottom-end left left-start left-end right right-start right-end'top'
theme主题风格'dark' | 'light''dark'
transition动画名称string'zoom-in'
duration动画时长,单位 msnumber300
show-arrow是否显示箭头booleantrue
lazy-render是否懒渲染booleantrue
close-on-click-outside点击元素外部后关闭booleantrue
disabled是否禁用booleanfalse
z-index层级number | string-

代替原始 Props

参数说明类型默认值
custom-id根节点idstring-
custom-class根节点类名ClassValue-
custom-style根节点样式StyleValue-

Events

事件名说明回调参数
click点击时触发event: MouseEvent
click-outside点击外部时触发event: MouseEvent
open打开时触发-
opened打开动画结束时触发-
close关闭时触发-
closed关闭动画结束时触发-

Methods

通过 ref 可调用以下方法

方法名说明参数
open打开气泡提示-
close关闭气泡提示-

Slots

名称说明
default触发容器
message提示信息

赣ICP备2025061025号-1