uni-app新建透明页面实现全局弹窗

需求背景

实现一个能遮住原生 tabbar 和 navbar 的全局操作框

原理

使用一个透明的页面来模拟弹窗,这个页面可以遮住原生 tabbar 和 navbar

页面配置

json 复制代码
{
    "path" : "pages/shootAtWill/shootAtWill",
    "style" : 
    {
        "navigationBarTitleText" : "随手拍",
        "navigationStyle": "custom",
        "backgroundColor": "transparent",
        "app-plus": {
            "animationType": "slide-in-bottom", // 我这边需求是从底部弹出
            "background": "transparent",
            "popGesture": "none",
            "bounce": "none",
            "titleNView": false,
            "animationDuration": 150
        }
    }
}

页面样式

html 复制代码
<style>
	page {
		/* 必须的样式,这是页面背景色为透明色 */
		background: transparent; 
	}
</style>
<style lang="scss" scoped>
  // 写你页面的其他样式
</style>

这样的话就新建成功了一个透明的页面,那么这个页面上的东西都可以遮挡住原生 tabbar 和 navbar

我还加了遮罩:

html 复制代码
<template>
  <view>
    <view class="modal" style="z-index: -1"></view>  
    
  </view>
</template>

<style lang="scss" scoped>
   .modal {
      position: fixed;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      background-color: rgba(0, 0, 0, 0.5);
	}
</style>

效果演示

相关推荐
Csvn2 小时前
WASM
前端
修己xj3 小时前
我用 AI 给自己写了一个 Markdown 编辑器,然后把它开源了
前端
FRing033 小时前
vue2干货总结2(v-bind、v-for、v-model、指令修饰符、v-bind操作class和style)
开发语言·前端·vue.js·vue2
幸运小猿4 小时前
模拟慢上传-处理超时重试image 丢失线上问题
前端·javascript·html
moshuying5 小时前
网购能买Token了!
前端
h_65432105 小时前
echarts实现柱状图加一条横线
前端·echarts
风骏时光牛马5 小时前
生成一个后端标题,只需要一个标题,不需要其他的任何文本。
前端
子非鱼@Itfuture5 小时前
关于前后端联调中登录状态/登录信息失效?
java·前端
郭小李5 小时前
openFeign入门
java·开发语言·前端
馒头不想说话6 小时前
AI当运营,帮你省人力
前端