Skip to content

气泡卡片 Popover


点击/鼠标移入元素,弹出气泡式的卡片浮层。

何时使用

  • 当目标元素有进一步的描述和相关操作时,可以收纳到卡片中,根据用户的操作行为进行展现。
  • 和 Tooltip 的区别是,用户可以对浮层上的元素进行操作,因此它可以承载更复杂的内容,比如链接或按钮等。

基本使用

Title

Content

Content

Show Code
vue
<script setup lang="ts">
function openChange (visible: boolean) {
  console.log('visible:', visible)
}
</script>
<template>
  <Popover title="Title" @open-change="openChange">
    <template #content>
      <p>Content</p>
      <p>Content</p>
    </template>
    <Button type="primary">Hover me</Button>
  </Popover>
</template>

不同的触发方式

Title

Content

Content

Show Code
vue
<template>
  <Popover title="Title" trigger="click">
    <template #content>
      <p>Content</p>
      <p>Content</p>
    </template>
    <Button type="primary">Click me</Button>
  </Popover>
</template>

自定义样式

TitleTitleTitleTitleTitleTitleTitleTitleTitle

Content

Content

Show Code
vue
<template>
  <Popover
    title="TitleTitleTitleTitleTitleTitleTitleTitleTitle"
    :max-width="240"
    :overlayStyle="{ padding: '12px 18px', borderRadius: '12px' }">
    <template #content>
      <p>Content</p>
      <p>Content</p>
    </template>
    <Button type="primary">Hover me</Button>
  </Popover>
</template>

APIs

参数说明类型默认值必传
title卡片标题string | slot''false
content卡片内容string | slot''false
maxWidth卡片内容最大宽度string | number'auto'false
trigger卡片触发方式'hover' | 'click''hover'false
overlayStyle卡片样式CSSProperties{}false

Events

事件名称说明参数
openChange显示隐藏的回调(visible: boolean) => void

Released under the MIT License.