Skip to content

Popup

演示

Popup 跨端示例与演示

弹出层配送方式

基础用法

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>

关闭按钮

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

Props

Prop类型默认值描述
visibleboolean | undefinedundefined受控显示状态
defaultVisiblebooleanfalse非受控初始显示状态
disabledboolean | undefinedundefined禁止内部触发显隐变更
position'center' | 'top' | 'bottom' | 'left' | 'right''bottom'弹出位置
overlaybooleantrue是否显示遮罩
closeablebooleanfalse是否显示关闭按钮
closeIconstring'×'关闭按钮内容
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自定义关闭按钮内容

Primitives

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