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>

效果演示

相关推荐
小小小小宇1 分钟前
Harness Engineering 与 AI 联动
前端
鱼人6 分钟前
HTML5 页面性能优化大全
前端
ping某7 分钟前
专栏-null 和 undefined 到底是什么?
前端·javascript·后端
用户9004633704011 分钟前
5MB vs 4KB vs 无限大:浏览器存储谁更强?
前端
小小小小宇22 分钟前
Harness Engineering 全解析与应用
前端
牧艺1 小时前
cos-design v3.0:从 15 个 Demo 到 49 个组件的视觉特效库
前端·视觉设计
lichenyang4531 小时前
ASCF 架构升级总览:WebRuntimePage 为什么要变薄
前端
道友可好1 小时前
从今天开始:你的第一个 Harness Engineering 实践
前端·人工智能·后端
Linsk1 小时前
组件 = 模板 + 业务逻辑
java·前端·vue.js
二月龙2 小时前
移动端 H5 页面开发:响应式适配 + 低版本兼容实战指南
前端