Skip to content

Overlay

Create a mask layer to emphasize specific page elements and prevent users from operating the content under the mask. It is generally used in pop-up window scenarios. All related pop-up window components of wu-ui use this component.

Platform compatibility

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

Basic usage

  • Configure whether to display the mask through the show parameter
  • When the mask is clicked, a click event will be sent. If this event is not needed, please set the mask-click-able parameter to false
vue
<template>
	<wu-overlay :show="show" @click="show = false"></wu-overlay>
</template>

<script>
	export default {
		data() {
			return {
				show: true
			}
		}
	}
</script>
<template>
	<wu-overlay :show="show" @click="show = false"></wu-overlay>
</template>

<script>
	export default {
		data() {
			return {
				show: true
			}
		}
	}
</script>

Embed content

Default slots allow you to embed arbitrary content on the mask layer

Note: If you do not want the click event of the slot slot content to bubble up to the mask, please add @tap.stop to the specified element.

vue
<template>
	<wu-overlay :show="show" @click="show = false">
		<view class="warp">
			<view class="rect" @tap.stop></view>
		</view>
	</wu-overlay>
</template>

<script>
	export default {
		data() {
			return {
				show: true
			}
		}
	}
</script>

<style scoped>
	.warp {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.rect {
		width: 120px;
		height: 120px;
		background-color: #fff;
	}
</style>
<template>
	<wu-overlay :show="show" @click="show = false">
		<view class="warp">
			<view class="rect" @tap.stop></view>
		</view>
	</wu-overlay>
</template>

<script>
	export default {
		data() {
			return {
				show: true
			}
		}
	}
</script>

<style scoped>
	.warp {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.rect {
		width: 120px;
		height: 120px;
		background-color: #fff;
	}
</style>

Mask style

  • Use duration to set the duration of mask fade in and out, unit ms
vue
<wu-overlay :show="show" :duration="400" :z-index ="999" :opacity="0.3"></wu-overlay>
<wu-overlay :show="show" :duration="400" :z-index ="999" :opacity="0.3"></wu-overlay>

API

Property nameDescriptionTypeDefault valueOptional value
showWhether to display the maskBooleanfalsetrue / false
zIndexz-index value of the pop-up layerNumberString10075
durationanimation duration, unit msString / Number300-
opacityopacity value, used as the fourth parameter of rgbaString / Number0.5-
Event nameDescriptionCallback parameters
clickClick the mask to send this event-
Slot NameDescription
defaultThe default slot for embedding content above the mask layer