使用自定义头固定定位标题栏也会上推,阻止上推的话,键盘不会自动弹起,输入框被键盘遮挡,试过使用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
})
}
})