收藏
回答

软键盘覆盖弹出层,onKeyboardHeightChange获取的键盘高度高于实际值?

用page-container做底部弹出,加上textarea做输入,结果弹出的软键盘会覆盖掉部分弹出层,曲线救国,当textarea获取/失去焦点是得到键盘高度,重设弹出层距底部距离,但是谁曾想获取的键盘高度明显高于实际值?自此无解了

<page-container 

  show="{{show}}"

  round="{{round}}"

  overlay="{{overlay}}"

  duration="{{duration}}"

  position="{{position}}"

  close-on-slide-down="{{false}}"

  custom-style="margin-bottom:{{keyboardheight}}px"

  overlay-style="{{overlayStyle}}"

  bindenter="onEnter"

>

  <view class="detail-page">

    <textarea class="pop-textarea" focus="{{focus}}" auto-focus="{{true}}" adjust-position="{{true}}" 

    show-confirm-bar="{{false}}" bindkeyboardheightchange="keyboardchange" placeholder="评论一下"/>

  </view>

  <view class="detail-button">

    <view class="plbtn"> 按钮 </view>

  </view>

</page-container>

比实际值高出一倍,有没有哪位大佬有解决办法

wx.onKeyboardHeightChange((result) => {

      this.setData({keyboardheight:result.height/2})

    })


回答关注问题邀请回答
收藏

2 个回答

  • 社区技术运营专员--许涛
    社区技术运营专员--许涛
    2022-11-19

    你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)

    2022-11-19
    有用
    回复
  • 发飙的蜗牛
    发飙的蜗牛
    2023-08-10

    你这个页面应该有tabbar,他算了tabbar的高度

    2023-08-10
    有用
    回复
登录 后发表内容