Skip to content

Popup 弹窗

基础用法

查看代码
vue
<template>
    <div style="display: flex; gap: 12px">
        <Button @click="openCenter = true">居中弹窗</Button>
        <Button @click="openBottom = true">底部弹窗</Button>
        <Popup v-model="openCenter" position="center">
            <div style="padding: 24px; background: #fff; border-radius: 8px; min-width: 200px">
                居中弹窗内容
                <div style="margin-top: 12px; text-align: right">
                    <Button @click="openCenter = false">关闭</Button>
                </div>
            </div>
        </Popup>
        <Popup v-model="openBottom" position="bottom">
            <div style="padding: 24px; background: #fff; border-radius: 12px 12px 0 0">
                底部弹窗内容
                <div style="margin-top: 12px; text-align: right">
                    <Button @click="openBottom = false">关闭</Button>
                </div>
            </div>
        </Popup>
    </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { Button, Popup } from "@a-drowned-fish/rox-v";

const openCenter = ref(false);
const openBottom = ref(false);
</script>

Props

参数说明类型默认值
modelValue (v-model)是否显示booleanfalse
toTeleport 目标节点string"body"
bg遮罩背景色string"rgba(0,0,0,.5)"
duration过渡动画时长(ms)number150
position弹层位置"top" | "bottom" | "left" | "right" | "center""bottom"
maskClosable点击遮罩是否关闭booleantrue
top / left / right / bottom弹层偏移string"0px"
zIndex层级number | string999
containerClass遮罩容器类名string""
contentClass内容容器类名string""

事件

事件名说明回调参数
update:modelValue显隐状态变化(value: boolean) => void

插槽

插槽名说明
default弹层内容(点击内容不会关闭,需自行处理)

基于 MIT 协议开源