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 分钟前
Vue3 零基础每日笔记(026):emit 子传父——defineEmits 与事件校验
前端·javascript·html·vue3
风骏时光牛马10 分钟前
6个高频实用技术脚本案例,覆盖运维与办公自动化(可直接复用)
前端
爱吃红星柚25 分钟前
【学习】Elpis 抽离与发布 npm 包
前端·前端框架·node.js
熊猫钓鱼>_>1 小时前
ArkTS 性能优化实战:从冷启动到长列表,一套可复现的实测方法论
app·harmonyos·arkts·鸿蒙·组件·性能·arkui
PedroQue991 小时前
0.5.0重磅发布:动画插件+H5体验全面优化
前端·uni-app
金虹桥程序员1 小时前
【动画】 📚 CSS 动画与 GPU 合成层优化全链路指南
前端·面试
程序员老赵1 小时前
Docker 部署填鸭表单完整教程:搭建私有化问卷与表单收集平台
前端·docker·开源
无限压榨切图仔1 小时前
向量库能搜到内容,为什么还不算学会 RAG
前端·agent
mmsx1 小时前
MapLibre 实战 11|用户说"我的地块丢了":一个 sealed class 图层模型,和四个让我重构三版的坑
android·前端·开源
xqchen1 小时前
代码差异可视化方案选型:diff2html 实战指南
前端