弹出层

介绍

弹出层,页面中的弹层。通常用于筛选,提示等功能。

基础用法

通过show属性控制弹出层的显示与隐藏。

<z-popup :show="show" :custom-style="{padding: '30px 50px'}" @close="hideBasic">
	内容
</z-popup>
data() {
	return {
		show: false
	}
},
methods: {
    hideBasic(){
        this.show = false;
    }
}

弹出位置

通过position属性控制弹出层的位置。可选值top,bottom,left,right

<z-popup :show="show" position="top" :custom-style="{height: '20%'}" @close="this.show = false" />
<z-popup :show="show" position="bottom" :custom-style="{height: '50%'}" @close="this.show = false" />
<z-popup :show="show" position="left" :custom-style="{width: '20%',height: '100%'}" @close="this.show = false" />
<z-popup :show="show" position="right" :custom-style="{width: '20%',height: '100%'}" @close="this.show = false" />

关闭图标

通过closeable属性控制弹出层是否显示关闭图标。通过close-icon可以设置关闭图标的名称。通过close-icon-size属性设置关闭图标的尺寸。通过close-icon-position属性设置关闭图标的位置。

<z-popup :show="show" closeable position="bottom" :custom-style="{height: '20%'}" @close="this.show = false" />

<!-- 自定义图标 -->
<z-popup :show="show" closeable close-icon-size="50rpx" close-icon="off_outline_close" position="bottom" :custom-style="{height:'20%'}" @close="this.show = false" />

<!-- 图标位置 -->
<z-popup :show="show" closeable close-icon-position="top-left" position="bottom" :custom-style="{height:'20%'}" @close="this.show = false" />

圆角弹窗

通过round属性设置弹出层为圆角。

<z-popup :show="show" round position="bottom" :custom-style="{height:'20%'}" @close="this.show = false" />

API

Props

参数 说明 类型 可选值 默认值
name 动画类型 string scale slide-up slide-down slide-left slide-right fade
show 是否显示弹出层 boolean false
z-index z-index 层级 number 100
overlay 是否显示遮罩层 boolean true
overlay-style 自定义遮罩层样式 string -
overlay-background 是否显示遮罩层背景颜色 boolean true
transition 动画名称 string -
duration 动画时长,单位为毫秒 number 300
lock-scroll 是否锁定背景滚动 boolean true
position 弹出位置 string top bottom right left center
round 是否显示为圆角 boolean false
custom-style 自定义样式 object -
close-on-click-overlay 是否在点击遮罩层后关闭 boolean true
closeable 是否显示关闭图标 boolean false
close-icon 关闭图标名称或图片链接 string close_big
close-icon-size 关闭图标大小 string -
safe-area-inset-bottom 是否留出底部安全距离 boolean true
safe-area-inset-top 是否留出顶部安全距离(状态栏高度) boolean false
close-icon-position 关闭图标位置 string top-left bottom-left bottom-right top-right

Events

事件名 回调参数 说明
click-overlay - 点击遮罩层事件
close - 关闭弹窗触发
before-enter - 弹窗弹出之前事件
enter - 弹窗弹出中事件
before-leave - 弹窗关闭之前事件
leave - 弹窗关闭中事件

Slots

名称 说明 Bindings
default 弹窗内容插槽