Skip to content

Popup ​

演示 ​

Popup 跨端示例与演示

H5 Live浏览器运行时实时交互
弹出层配送方式

基础用法 ​

vue
<script setup lang="ts">
import { ref } from 'vue'

const visible = ref(false)
</script>

<template>
  <VButton @click="visible = true">
    打开弹出层
  </VButton>
  <VPopup v-model:visible="visible" position="bottom" round closeable>
    <div class="popup-body">
      弹层内容
    </div>
  </VPopup>
</template>

弹出位置 ​

vue
<template>
  <VPopup v-model:visible="visible" position="top" />
  <VPopup v-model:visible="visible" position="bottom" />
  <VPopup v-model:visible="visible" position="left" />
  <VPopup v-model:visible="visible" position="right" />
  <VPopup v-model:visible="visible" position="center" />
</template>

关闭按钮 ​

closeIcon 接收 VIcon 支持的内置名称(例如 close、back、check 或 chevron-left),默认使用 close。需要自定义图标组件或图形内容时,使用 #closeIcon 插槽。

vue
<template>
  <VPopup v-model:visible="visible" closeable close-icon="back" />

  <VPopup v-model:visible="customVisible" closeable>
    <template #closeIcon>
      <VIcon name="check" />
    </template>
  </VPopup>
</template>

Props ​

Prop类型默认值描述
visibleboolean | undefinedundefined受控显示状态
defaultVisiblebooleanfalse非受控初始显示状态
disabledboolean | undefinedundefined禁止内部触发显隐变更
position'center' | 'top' | 'bottom' | 'left' | 'right''bottom'弹出位置
overlaybooleantrue是否显示遮罩
closeablebooleanfalse是否显示关闭按钮
closeIconstring'close'传给 VIcon 的内置图标名称
closeIconPosition'top-left' | 'top-right' | 'bottom-left' | 'bottom-right''top-right'关闭按钮位置标记
roundbooleanfalse是否开启圆角态
safeAreaInsetBottombooleanfalse是否标记底部安全区
lockScrollbooleanfalse显示时锁定页面滚动
closeOnClickOverlaybooleantrue点击遮罩是否关闭
zIndexnumber | stringundefined弹层层级
durationnumber | stringundefined动画时长,数字按秒处理
destroyOnClosebooleantrue关闭时是否销毁内容

Events ​

EventPayload描述
update:visibleboolean受控同步事件
visibleChangeboolean显隐状态变更
closevoid请求关闭
clickOverlayvoid点击遮罩

Slots ​

Slot描述
default弹层主体内容
closeIcon替换默认 VIcon 的自定义关闭图标内容

Primitives

PopupRoot 使用 usePopupRoot 管理显隐、遮罩点击和 Escape 关闭;UI 包只保留 Varo 风格组件入口。