5***@qq.com
5***@qq.com
  • 发布:2021-04-01 22:33
  • 更新:2021-04-01 22:33
  • 阅读:878

微信小程序顶部导航栏自定义组件

分类:uni-app

navHeader.vue,已经计算好高度,调用: <navHeader></navHeader>

<template>  
    <view>  
        <view class="bg-orange" :style="'height:'+statusBarHeight+'px'"></view>  
        <view class="bg-orange flex align-center justify-center" :style="'height:'+navBarHeight+'px'">  
            <view class="text-lg">  
                {{title}}  
            </view>  
        </view>  
    </view>  
</template>  

<script>  
    export default {  
        name:"navHeader",  
        data() {  
            return {  
                statusBarHeight: 0,  
                navBarHeight: 0,  
                title:'测试'  
            };  
        },  
        created() {  
            this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;  
             let plat = uni.getSystemInfoSync().platform;  
             this.navBarHeight = 44;  
             if(plat=='android'){  
                  this.navBarHeight = 48;  
             }  
        }  
    }  
</script>  

<style>  

</style>  
0 关注 分享

要回复文章请先登录注册