解决方案:利用输入框焦点事件,结合监听屏幕高度变化解决此问题,代码如下:
<template> <view class="box"> <view> <input type="text" placeholder="请输入框一" @focus="focus" @blur="blur"> </view> <view> <input type="text" placeholder="请输入框二" @focus="focus" @blur="blur"> </view> <view style="text-align: center;position: fixed;bottom: 70rpx;width: 100%;" v-if="footer"> 客服热线:400-023-000 </view> </view> </template> <script> export default { data() { return { footer: true, windowHeight: '' } }, onLoad() { uni.getSystemInfo({ success: (res)=> { this.windowHeight = res.windowHeight; } }); uni.onWindowResize((res) => { if(res.size.windowHeight < this.windowHeight){ this.footer= false }else{ this.footer = true } }) }, methods:{ focus(){ this.footer= false }, blur(){ this.footer = true } } } </script>