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>

效果演示

相关推荐
变与不变8061 天前
jQuery怎么使用
前端·javascript
神膘护体小月半1 天前
flex 布局的 order 属性
前端·css
paopaokaka_luck1 天前
流浪动物救助与收养系统(DeepSeek AI对话、 ECharts多维分析、救助流程衔接、领养与回访衔接、 捐赠确认与公示、志愿者协作)
java·前端·javascript·人工智能·mysql·echarts·推荐算法
仰望.1 天前
vue 表格组件 vxe-table 树表格懒加载支持拖拽排序的详细用法
前端·javascript·vue.js·vxe-table
前端 贾公子1 天前
vite-plugin-uni-manifest 升级指南
前端
小码哥_常1 天前
iPhone 用户传了张 HEIC,我的前端崩了
前端
小码哥_常1 天前
你发的原图可能暴露你家地址——聊聊图片 EXIF 隐私
前端
java1234_小锋1 天前
【技术专题】CSS3 网页技术 - CSS3 优先级
前端·css·css3
鸿蒙开发1 天前
共享 Schema 与 SchemaFactory
前端·后端·harmonyos
屏什么录1 天前
录屏超过两小时就卡顿崩盘?从参数调优到代码实现,一文彻底搞定长时间录屏
前端·音视频开发