emis-sapp/components/tpx-navigation-height/tpx-navigation-height.vue
2024-07-19 00:45:11 +08:00

54 lines
991 B
Vue

<template>
<view class="" :style="contStyle">
<slot></slot>
</view>
</template>
<script>
export default {
computed: {
contStyle(){
let sty = ``
sty += `padding-top: ${this.menuTop}rpx;`
if(typeof this.menuHeight != 'undefined') {
sty += `min-height:${this.menuHeight}rpx;`
}
return sty
}
},
props: {
},
data() {
return {
menuTop: 60, // 默认60
menuHeight: undefined, //
}
},
created() {
this.getMenuButton()
},
onHide() {
},
unmounted() {},
methods: {
getMenuButton(){
const that = this;
// 获取系统信息
const systemInfo = wx.getSystemInfoSync();
if(uni.getMenuButtonBoundingClientRect) {
// 小程序 胶囊按钮位置信息
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
this.menuTop = menuButtonInfo.top + systemInfo.statusBarHeight;
this.menuHeight = menuButtonInfo.height;
}
}
}
}
</script>
<style scoped lang="scss">
</style>