Skip to content

m-popup 弹出层

简述

弹出层容器,用于展示弹窗、菜单等内容,支持从顶部、底部、中间弹出。

注意

请以 uni_modules/m-unix 与本文为准;各端差异以 uni-app 与各平台官方文档为准。涉及隐私能力(相册、定位、剪贴板、手机号等)需在 manifest 与后台完成配置。

平台差异说明

App(vue)App(nvue)H5小程序

演示地址

与线上 H5 演示基座 分包一致(文档站右下角预览 iframe 亦指向同一路径)。

类型地址
分包路径pages_demo/popup/popup
线上 H5(hash)打开演示

基本使用

uvue
<template>
	<view>
		<m-popup
			:show="show"
			position="bottom"
			round
			closeable
			@close="show = false"
		>
			<view>
				<text>弹出内容</text>
			</view>
		</m-popup>
	</view>
</template>

Props

参数说明类型默认值
show是否显示(与 visible 二选一,满足其一即打开)booleanfalse
visibleshow,兼容旧字段booleanfalse
position弹出位置,见下表stringbottom
round是否圆角booleantrue
overlayOpacity遮罩不透明度 0~1number | string0.5
closeable是否显示右上角关闭booleanfalse
closeOnClickOverlay点击遮罩是否关闭booleantrue
zIndex内容层 z-index(遮罩为 zIndex - 1number | string999
maxHeight内容最大高度(vh);left / right / fullscreen 时内部为 100% 满高number | string80
animation是否启用显示/隐藏过渡booleantrue
duration过渡时长(毫秒),与 CSS 一致number300

position 可选值

说明
top从上滑入
bottom从下滑入(默认)
center居中
left左侧抽屉(高度满屏)
right右侧抽屉(高度满屏)
fullscreen全屏

Events

事件名说明回调参数
update:show显隐同步(与 v-model:show 配合)boolean
update:visibleupdate:showboolean
close关闭(按钮、遮罩等)
overlay-click点击遮罩

插槽

名称说明
default弹出层内容

示例

底部弹出

uvue
<m-popup
	:show="show"
	position="bottom"
	round
	closeable
	@close="show = false"
>
	<view>
		<text>底部弹出内容</text>
	</view>
</m-popup>

中间弹出弹窗

uvue
<m-popup
	:show="show"
	position="center"
	round
>
	<view class="dialog">
		<text>弹窗内容</text>
	</view>
</m-popup>

Released under the MIT License.