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

需求背景

实现一个能遮住原生 tabbarnavbar 的全局操作框

原理

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

页面配置

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>

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

我还加了遮罩:

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>

效果演示

相关推荐
Shi_haoliu6 小时前
openClaw源码部署-linux
前端·python·ai·openclaw
程序员小寒6 小时前
前端性能优化之白屏、卡顿指标和网络环境采集篇
前端·javascript·网络·性能优化
烛阴7 小时前
Claude CLI AskUserQuestion 工具详解:让 AI 开口问你
前端·claude
wal13145207 小时前
OpenClaw教程(九)—— 彻底告别!OpenClaw 卸载不残留指南
前端·网络·人工智能·chrome·安全·openclaw
mon_star°7 小时前
在TypeScript中,接口MenuItem定义中,为什么有的属性带问号?,有的不带呢?
前端
牛奶8 小时前
分享一个开源项目,让 AI 辅助开发真正高效起来
前端·人工智能·全栈
次顶级8 小时前
表单多文件上传和其他参数处理
前端·javascript·html
why技术9 小时前
我拿到了腾讯QClaw的内测码,然后沉默了。
前端·后端
谪星·阿凯9 小时前
XSS漏洞解析博客
前端·web安全·xss