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>

效果演示

相关推荐
浮游本尊17 小时前
React 18.x 学习计划 - 第十天:React综合实践与项目构建
前端·学习·react.js
阿蔹17 小时前
UI测试自动化--Web--Python_Selenium-元素定位
前端·ui·自动化
万少17 小时前
【鸿蒙心迹】-03-自然壁纸实战教程-项目结构介绍
前端
万少17 小时前
【鸿蒙心迹】- 02-自然壁纸实战教程-AGC 新建项目
前端
南望无一18 小时前
Vite拆包后Chunk级别的循环依赖分析及解决方案
前端·vite
快乐星球喂18 小时前
子组件和父组件之间优雅通信---松耦合
前端·vue.js
风止何安啊18 小时前
Steam玩累了?那用 Node.js 写个小游戏:手把手玩懂 JS 运行环境
前端·javascript·node.js
不想秃头的程序员18 小时前
JS原型链详解
前端·面试
simon912418 小时前
ElementUI:表格如何展示超出单元格的内容且不影响单元格?
前端·vue.js·element
天外天-亮18 小时前
Vue 中常用的指令
前端·javascript·vue.js