当前位置: 首页 > news >正文

uniapp 设置安全区域

<!-- 获取安全区域 -->
<script setup lang="ts">
import { computed, ref } from 'vue'let systemType = ref('1')
// #ifdef APP-PLUS || H5  || APP-PLUS-NVUE
systemType.value = '1'
const { safeAreaInsets } = uni.getSystemInfoSync()
console.log(safeAreaInsets, 'safeAreaInsets')
const prop = defineProps({title: {type: String,default: '消息',},
})
// #endif// #ifdef MP-WEIXIN
systemType.value = '2'
const navbarHeight = ref(0)
//计算刘海状态栏
navbarHeight.value = uni.getSystemInfoSync().statusBarHeight || 0
//计算胶囊区域的高度
let { top, height } = uni.getMenuButtonBoundingClientRect()
const titleBarHeight = computed(() => {return (top - navbarHeight.value) * 2 + height
})
// #endif
</script><template><view v-if="systemType == '1'" class="navbar" :style="{ paddingTop: safeAreaInsets?.top + 'rpx' }"><view class="search">{{ title }}</view></view><view v-if="systemType == '2'"><view class="fill" :style="{ height: navbarHeight + 'px' }"></view><view class="title" :style="{ height: titleBarHeight + 'px' }"> 消息 </view></view>
</template><style lang="scss">
.navbar {background-size: cover;position: relative;display: flex;flex-direction: column;padding-top: 20px;// .leftBack {//   position: absolute;//  top: 200rpx;// }.search {display: flex;align-items: center;justify-content: center;padding: 0rpx 10rpx 0 26rpx;height: 64rpx;line-break: 64rpx;//ui标记距离上面22rpxmargin: 44rpx 20rpx 0 20rpx;color: #1f1f1f;font-weight: 600;font-size: 28rpx;border-radius: 32rpx;}
}
.fill {width: 100%;
}
.title {width: 100%;display: flex;justify-content: center;align-items: center;
}
</style>

uniapp 设置安全区域以及导航栏和胶囊对齐 要注意app没有胶囊没法获取 要另外写样式(已完善)

ps:真就是每个公司总有那么几个表现狗 真他妈的恶心 得拓展一下自己的知识宽度 找下家了

 

http://www.lryc.cn/news/483575.html

相关文章:

  • 渐进式JavaScript框架Vue 3 入门
  • 【真题笔记】21年系统架构设计师案例理论点总结
  • PostgreSQL的奥秘:深入探究事务与锁的秘密世界
  • Python进行GRPC和Dubbo协议的高级测试
  • 全程云OA系统QCPES.asmx存在SQL注入漏洞
  • 从建立TRUST到实现FAIR:可持续海洋经济的数据管理
  • 基于SSM的“汽车销售分析与管理系统”的设计与实现(源码+数据库+文档+PPT)
  • vs2015QT项目添加多语言翻译总结
  • 替换OpenTSDB和HBase,宝武集团使用IoTDB助力钢铁设备智能运维
  • MathGPT的原理介绍,在中小学数学教学的应用场景,以及代码样例实现
  • 前端框架大比拼:React.js, Vue.js 及 Angular 的优势与适用场景探讨
  • MySQL45讲 第二十讲 幻读是什么,幻读有什么问题?
  • MySQL技巧之跨服务器数据查询:进阶篇-从A数据库复制到B数据库的表中
  • 【论文阅读】利用SEM二维图像表征黏土矿物三维结构
  • 可靠UDP协议(KCP)使用说明
  • ffmpeg+D3D实现的MFC音视频播放器,支持录像、截图、音视频播放、码流信息显示等功能
  • 【Flink】-- flink新版本发布:v2.0-preview1
  • Node.js 版本管理的最终答案 Volta
  • 蓝桥杯每日真题 - 第11天
  • Vue vs React:两大前端框架的区别解析
  • 【树莓派raspberrypi烧录Ubuntu远程桌面登入树莓派】
  • c# 调用c++ 的dll 出现找不到函数入口点
  • LInux——环境基础开发工具使用(正在更新中...)
  • linux 内核asmlinkage关键字总结
  • ⚡️如何在 React 和 Next.js 项目里优雅的使用 Zustand
  • Pinpoint(APM)进阶--Pinot指标采集(System Metric/Inspector)
  • Mysql:使用binlog的一些常用技巧
  • Electron 项目启动外部可执行文件的几种方式
  • 前端开发中常用的包管理器(npm、yarn、pnpm、bower、parcel)
  • Linux入门:环境变量与进程地址空间