uni-app获取设备底部安全区高度,解决自定义底部tabBar
作者:
Cola_Mr | 来源:发表于
2023-08-07 14:37 被阅读0次// app.vue
onLaunch: function () {
const result = uni.getSystemInfoSync();
this.globalData.safeareaHeight = result.screenHeight - result.safeArea.bottom;
}
// components/menu.vue
<template>
<view>
<view>
<view>导航一</view>
<view>导航二</view>
<view>导航三</view>
<view>导航四</view>
</view>
<view
:style="{ paddingBottom: safeareaHeight + 'px' }"
class="safearea"
></view>
</view>
</template>
<script>
const app = getApp();
export default {
data() {
return {
safeareaHeight: 0,
};
},
mounted() {
if (app.globalData.safeareaHeight > 0) {
this.safeareaHeight = app.globalData.safeareaHeight;
}
}
};
</script>
本文标题:uni-app获取设备底部安全区高度,解决自定义底部tabBar
本文链接:https://www.haomeiwen.com/subject/wfegpdtx.html
网友评论