uniapp 顶部导航栏 高度自适应

index.vue

<template>
    <view>
        <view :style="'padding-top:'+ aaa +'px;height:'+bbb+'px;'">
    </view>      
</template>

index.js

export default {
    data() {  
        return {
           aaa:'',
          bbb:'',
        }
    },
    onLoad() {
        const menu = uni.getMenuButtonBoundingClientRect()
      this.aaa=menu.top;
      this.bbb=menu.height;
    }
}

 

posted @ 2021-10-18 16:08  smile_Lu  阅读(1378)  评论(0)    收藏  举报