<template>
<view :style="{marginTop: systemBarHeight + 'px'}">
...
</view>
</template>
<script>
export default {
data() {
return {
// 系统状态栏的高度
systemBarHeight: 0
};
},
methods: {
// 获取系统栏高度
getSysteminfo() {
uni.getSystemInfo({
success: res => {
console.log(res.statusBarHeight)
this.systemBarHeight = res.statusBarHeight;
}
});
}
},
onLoad() {
this.getSysteminfo()
}
}
</script>
<style lang="scss">
</style>
uniapp获取顶部状态栏高度
最新推荐文章于 2024-04-11 11:44:55 发布