html52.com
我爱小程序-开发者交流社区

textarea上推页面使标题消失?

使用自定义头固定定位标题栏也会上推,阻止上推的话,键盘不会自动弹起,输入框被键盘遮挡,试过使用scroll-into-view属性,输入框聚焦时定位到下一个,不起效果,有没有哪个大佬给点思路,谢谢 以下是代码片段 https://developers.weixin.qq.com/s/B1R6zqm27nC8

网友回复

______:

大概思路:使用position: fixed,给textarea绑定bindkeyboardheightchange事件,当键盘高度变化时更新position: fixed元素的top值。

<view class="fixed" style="top: {{fixedTop}}px">fixed on the top</view>
...

<textarea placeholder="请填写" bindkeyboardheightchange="onKeyboardHeightChange"></textarea>


.fixed {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
}


Page({
data: {
  fixedTop: 0
},
onKeyboardHeightChange(e) {
  this.setData({
    fixedTop: e.detail.height > 0 ? e.detail.height : 0
  })
}
})

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付