看了好多文章都感觉麻烦,这里说下我的思路,动态的计算内容距离上边距的宽度即可。
<template>
...
<!--必须使用相对定位,绝对定位和fiexd还是会被键盘顶起来-->
<view :style="{position:'relative',width:'100%',height:'100px',marginTop:marginTopHeight+'px'}">
<!--底部区域的内容-->
</view>
</template>
data(){
//窗口高度
widowsHeight: 0,
// 底部按钮区域距离上面内容的高度
marginTopHeight:0,
},
onLoad(option) {
// 获取当前窗口高度,用来计算底部签到按钮的位置
uni.getSystemInfo({
success: (res)=> {
this.windowHeight = res.windowHeight;
// 底部区域距离上边内容距离 = 窗口高度 - 底部区域本身高度 - 上边内容高度
this.marginTopHeight = this.windowHeight - 120 - 460;
}
});
}