// 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>