uni-app中textarea输入框键盘弹起导致页面上移如何解决?

uni-app textarea输入框,app聊天窗口键盘弹起时页面整体上移问题?

lQDPJwD63mucMunNBP_NAj-wnbttd0ZqT9EJ4VqilWTjAA_575_1279.jpglQDPKILyX4DsEGnNBP_NAj-wM_2by2_Zy-4J4VwwwusaAA_575_1279.jpg
第一张图是设置"softinputMode": "adjustPan",安卓各个手机厂商表现都不一样,有的是好的,有的直接弹起
第一张图是设置"softinputMode": "adjustResize",这样自适应会出现中间区域闪现黑色,这个要怎么解决啊

阅读 726
2 个回答

adjustPan
监听键盘高度
transform 手动上移

manifest.json

"softinputMode": "adjustPan"

页面逻辑

data() {
  return {
    keyboardHeight: 0
  }
},
mounted() {
  uni.onKeyboardHeightChange(res => {
    this.keyboardHeight = res.height
  })
}

输入框

<view
  class="input"
  :style="{ transform: translateY(-${keyboardHeight}px) }"
>
  <textarea :adjust-position="false"/>
</view>

消息区

<scroll-view :style="{ paddingBottom: keyboardHeight + 'px' }">
</scroll-view>