自定义tabbar组件-图标padding距离适配

282 阅读1分钟

就是图下标注区域

如果是安卓tabbar图标距离是10rpx,苹果是20rpx。

image.png

都是在自定义tabbarVue组件内操作

<template>
	<view :style="{height: tabBarHeight}" class="tab-bar" >
		<view class="content" :style="{'padding-top':barpadbtm == 0 ? '10rpx' :'20rpx'}">
                
             //中间省略  
                
    	</view>
</template>


     data() {
	 return {	
		   barpadbtm:0,
                   }
                },
                created() {
			uni.getSystemInfo({
			  success: (res) => {
				  console.log(res,'tabBarHeight')
			    this.tabBarHeight = res.screenHeight - res.safeArea.bottom + 49 +'px'
				// 计算padding
				this.barpadbtm = res.screenHeight - res.safeArea.bottom  
			  }
			})
		     },

(以为把tabbar高度适配一下就完了,没想到图标padding也要适配...)