一、创建页面,并配置pages.json文件(仅app端可以看见上一个页面内容)
{
"path" : "pages/blogPopup/blogPopup",
"style" :
{
"navigationBarTitleText" : "",
"enablePullDownRefresh" : false,
"navigationStyle": "custom",
"app-plus": {
"animationType": "fade-in", // 设置fade-in淡入动画,为最合理的动画类型
"background": "transparent", // 背景透明
"backgroundColor": "transparent", // 背景透明
"webviewBGTransparent": true,
"mask": "none",
"popGesture": "none", // 关闭IOS屏幕左边滑动关闭当前页面的功能
"bounce": "none" // 将回弹属性关掉
}
}
}
二、"background": "transparent",已经设置了页面背景为透明,再设置页面一下背景遮罩效果
在此注意 切勿将style 添加scoped 切勿!! 切勿 !! 切勿!! 不然手机端效果显示会失效
page {
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.4);
}
三、开始页面布局,图片按自己的来就可以了
<template>
<view class="informantion_mask" @tap="closeWindow">
<view class="informantion_content" @tap.stop.prevent>
<view class="mask-header">
<image src="../../static/images/clear.png" mode="aspectFit" @click="closeWindow"></image>
</view>
<view class="informantion-title">
<p class="informantion-title-p">开启消息通知</p>
<span class="informantion-title-span">不要错过你的特别关心的重要通知,每天都要有干货推荐</span>
</view>
<view class="informantion-btn">
<button type="primary">去开启</button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
//点击mask消失,由于是页面实际相当于返回
closeWindow() {
uni.navigateBack({
delta: 1
})
}
}
}
</script>
<style lang="scss">
page {
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.4);
}
.informantion_mask {
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.informantion_content {
width: 600rpx;
height: 820rpx;
overflow: hidden;
border-radius: 10rpx;
background-color: white;
display: flex;
flex-direction: column;
justify-content: space-between;
padding-bottom: 20rpx;
}
.mask-header {
height: 400rpx;
position: relative;
background-image: url('../../static/images/bj.png');
background-repeat: no-repeat;
background-size: cover;
image {
width: 40rpx;
height: 40rpx;
position: absolute;
top: 20rpx;
right: 20rpx;
}
}
.informantion-title {
text-align: center;
padding: 0 40rpx;
p {
font-size: 35rpx;
font-weight: bold;
line-height: 80rpx;
}
span {
color: #6C6C6C;
}
}
.informantion-btn {
height: 93rpx;
width: 80%;
margin: 0 auto;
}
</style>
四、 一定要设置 @tap.stop.prevent 阻止事件冒泡
五、打开弹窗
...
uni.navigateTo({
url: '/pages/blogPopup/blogPopup'
})
...
如有不足,望大家多多指点! 谢谢!