Skip to content

This component is used to display pop-up windows, information prompts and other content, and supports top, bottom, left, right and middle pop-ups. Only components provide containers, and the internal content is customized by the user, with super scalability and silky animation.

Platform compatibility

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

Basic usage

  • The content of the pop-up layer is passed in through slot and is customized by the user
  • Control the opening and closing of the popup layer by calling open() and close() through ref
vue
<template>
	<view>
		<wu-popup ref="popup" @change="change">
			<view>
				<text>
                    君不见黄河之水天上来,奔流到海不复回。君不见高堂明镜悲白发,朝如青丝暮成雪。
                    人生得意须尽欢,莫使金樽空对月。天生我材必有用,千金散尽还复来。
                    烹羊宰牛且为乐,会须一饮三百杯。
                    岑夫子,丹丘生,将进酒,杯莫停。与君歌一曲,请君为我侧耳听。
                    钟鼓馔玉不足贵,但愿长醉不复醒。古来圣贤皆寂寞,惟有饮者留其名。
                    陈王昔时宴平乐,斗酒十千恣欢谑。主人何为言少钱,径须沽取对君酌。
                    五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。
                </text>
			</view>
		</wu-popup>
		<button @click="open">open</button>
	</view>
</template>
<script>
	export default {
		methods: {
			open(){
				this.$refs.popup.open('top');
			},
			change(e){
				console.log('弹窗状态改变:',e);
			}
		}
	}
</script>
<template>
	<view>
		<wu-popup ref="popup" @change="change">
			<view>
				<text>
                    君不见黄河之水天上来,奔流到海不复回。君不见高堂明镜悲白发,朝如青丝暮成雪。
                    人生得意须尽欢,莫使金樽空对月。天生我材必有用,千金散尽还复来。
                    烹羊宰牛且为乐,会须一饮三百杯。
                    岑夫子,丹丘生,将进酒,杯莫停。与君歌一曲,请君为我侧耳听。
                    钟鼓馔玉不足贵,但愿长醉不复醒。古来圣贤皆寂寞,惟有饮者留其名。
                    陈王昔时宴平乐,斗酒十千恣欢谑。主人何为言少钱,径须沽取对君酌。
                    五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。
                </text>
			</view>
		</wu-popup>
		<button @click="open">open</button>
	</view>
</template>
<script>
	export default {
		methods: {
			open(){
				this.$refs.popup.open('top');
			},
			change(e){
				console.log('弹窗状态改变:',e);
			}
		}
	}
</script>

Set the direction of the pop-up layer

  • Through the mode attribute setting, it can be set to left, top, right, bottom, center, the default is center
  • You can also pass a parameter through the open() method to replace the mode attribute, such as the basic usage above.
vue
<template>
	<view>
		<wu-popup ref="popup" mode="center" @change="change">
			<view style="width: 600rpx;">
				<text>
                    君不见黄河之水天上来,奔流到海不复回。君不见高堂明镜悲白发,朝如青丝暮成雪。
                    人生得意须尽欢,莫使金樽空对月。天生我材必有用,千金散尽还复来。
                    烹羊宰牛且为乐,会须一饮三百杯。
                    岑夫子,丹丘生,将进酒,杯莫停。与君歌一曲,请君为我侧耳听。
                    钟鼓馔玉不足贵,但愿长醉不复醒。古来圣贤皆寂寞,惟有饮者留其名。
                    陈王昔时宴平乐,斗酒十千恣欢谑。主人何为言少钱,径须沽取对君酌。
                    五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。
                </text>
			</view>
		</wu-popup>
		<button @click="open">打开</button>
	</view>
</template>
<script>
	export default {
		methods: {
			open(){
				this.$refs.popup.open();
			},
			change(e){
				console.log('弹窗状态改变:',e);
			}
		}
	}
</script>
<template>
	<view>
		<wu-popup ref="popup" mode="center" @change="change">
			<view style="width: 600rpx;">
				<text>
                    君不见黄河之水天上来,奔流到海不复回。君不见高堂明镜悲白发,朝如青丝暮成雪。
                    人生得意须尽欢,莫使金樽空对月。天生我材必有用,千金散尽还复来。
                    烹羊宰牛且为乐,会须一饮三百杯。
                    岑夫子,丹丘生,将进酒,杯莫停。与君歌一曲,请君为我侧耳听。
                    钟鼓馔玉不足贵,但愿长醉不复醒。古来圣贤皆寂寞,惟有饮者留其名。
                    陈王昔时宴平乐,斗酒十千恣欢谑。主人何为言少钱,径须沽取对君酌。
                    五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。
                </text>
			</view>
		</wu-popup>
		<button @click="open">打开</button>
	</view>
</template>
<script>
	export default {
		methods: {
			open(){
				this.$refs.popup.open();
			},
			change(e){
				console.log('弹窗状态改变:',e);
			}
		}
	}
</script>

Disable click mask off

By default, clicking on the mask will automatically close the pop-up window. If you do not want to click to close, you only need to set closeOnClickOverlay to false. At this time, to close wu-popup, you can only manually call the close() method .

vue
<template>
	<view>
		<wu-popup ref="popup" :close-on-click-overlay="false">
			<view style="width: 600rpx;">
				<text>
                    君不见黄河之水天上来,奔流到海不复回。君不见高堂明镜悲白发,朝如青丝暮成雪。
                    人生得意须尽欢,莫使金樽空对月。天生我材必有用,千金散尽还复来。
                    烹羊宰牛且为乐,会须一饮三百杯。
                    岑夫子,丹丘生,将进酒,杯莫停。与君歌一曲,请君为我侧耳听。
                    钟鼓馔玉不足贵,但愿长醉不复醒。古来圣贤皆寂寞,惟有饮者留其名。
                    陈王昔时宴平乐,斗酒十千恣欢谑。主人何为言少钱,径须沽取对君酌。
                    五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。
                </text>
				<button @click="close">关闭</button>
			</view>
		</wu-popup>
		<button @click="open">打开</button>
	</view>
</template>
<script>
	export default {
		methods: {
			open(){
				this.$refs.popup.open();
			},
			close(){
				this.$refs.popup.close();
			}
		}
	}
</script>
<template>
	<view>
		<wu-popup ref="popup" :close-on-click-overlay="false">
			<view style="width: 600rpx;">
				<text>
                    君不见黄河之水天上来,奔流到海不复回。君不见高堂明镜悲白发,朝如青丝暮成雪。
                    人生得意须尽欢,莫使金樽空对月。天生我材必有用,千金散尽还复来。
                    烹羊宰牛且为乐,会须一饮三百杯。
                    岑夫子,丹丘生,将进酒,杯莫停。与君歌一曲,请君为我侧耳听。
                    钟鼓馔玉不足贵,但愿长醉不复醒。古来圣贤皆寂寞,惟有饮者留其名。
                    陈王昔时宴平乐,斗酒十千恣欢谑。主人何为言少钱,径须沽取对君酌。
                    五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。
                </text>
				<button @click="close">关闭</button>
			</view>
		</wu-popup>
		<button @click="open">打开</button>
	</view>
</template>
<script>
	export default {
		methods: {
			open(){
				this.$refs.popup.open();
			},
			close(){
				this.$refs.popup.close();
			}
		}
	}
</script>

API

Property nameDescriptionTypeDefault valueOptional value
modePopup mode: top - top popup, bottom - bottom popup, left - left popup, right - right popup, center - middle popupStringcentertop / bottom /left/right/center
durationanimation duration, unit msString / Number300-
overlaywhether to display the maskBooleantruetrue / false
overlayStyleMask layer style: generally used to modify the mask color, such as: {background: 'rgba(3, 100, 219, 0.5)'}Object / String--
overlayOpacityMask transparency, between 0-1, do not share with overlayStyleNumber / String0.5-
closeOnClickOverlayWhether to close the pop-up window when clicking on the maskBooleantruetrue / false
zIndexz-index value of the pop-up layerNumberString10075
safeAreaInsetTopWhether to leave the top safe area (status bar height)Booleanfalsetrue / false
safeAreaInsetBottomWhether to leave the bottom safe area for adaptationBooleantruetrue / false
closeableWhether to display the close iconBooleanfalsetrue / false
closeIconPosCustomize the close icon position, top-left - upper left corner, top-right - upper right corner, bottom-left - lower left corner, bottom-right - lower right cornerStringtop-righttop-right / top-left / bottom-left / bottom-right
zoomWhether to enable zoom when mode=centerBooleantruetrue / false
bgColorBackground color, set to "" or none to remove the default white backgroundStringnone-
roundSet the rounded corner value, only valid for mode = topbottomcenterNumber / String 0
customStyleDefine the external style needed for the content areaObject--
Method nameDescriptionParameters
openOpen the pop-up layeropen(type: String), if there are parameters, the mode attribute will be replaced
closeClose the popup layer-
Event nameDescriptionCallback parameters
changeTriggered when the pop-up layer status changese = {show: true | false, type: current mode}
maskClickClick on the mask layer to trigger-
Slot NameDescription
defaultcustom content