uni-app textarea组件的adjust-position设置为false之后键盘弹出之后页面能够进行滚动

uni-app textarea组件的adjust-position设置为false之后键盘弹出之后页面能够进行滚动

类别 信息
产品分类 uniapp/App
PC开发环境 Windows
版本号 win11
HBuilderX 正式
版本号 4.76
手机系统 Android
版本号 Android 16
手机厂商 vivo
手机机型 s30
页面类型 vue
vue版本 vue2
打包方式 云端
项目创建方式 HBuilderX

示例代码:

<view class="u-textarea" :class="textareaClass" :style="[textareaStyle]">  
    <textarea class="u-textarea__field" :value="innerValue" :style="{ height: $u.addUnit(height) }"  
        :placeholder="placeholder" :placeholder-style="$u.addStyle(placeholderStyle, 'string')"  
        :placeholder-class="placeholderClass" :disabled="disabled" :focus="focus" :autoHeight="autoHeight"  
        :fixed="fixed" :cursorSpacing="cursorSpacing" :cursor="cursor" :showConfirmBar="showConfirmBar"  
        :selectionStart="selectionStart" :selectionEnd="selectionEnd" :adjust-position="false"  
        :disableDefaultPadding="disableDefaultPadding" :holdKeyboard="holdKeyboard" :maxlength="maxlength"  
        :confirmType="confirmType" :ignoreCompositionEvent="ignoreCompositionEvent" @focus="onFocus" @blur="onBlur"  
        @linechange="onLinechange" @input="onInput" @confirm="onConfirm"  
        @keyboardheightchange="onKeyboardheightchange"></textarea>  
    <text class="u-textarea__count" :style="{  
            'background-color': disabled ? 'transparent' : '#fff',  
        }" v-if="count">{{ innerValue.length }}/{{ maxlength }}</text>  
</view>  

可以查看到:adjust-position="false"直接强制设置为false

操作步骤:

vivo s30键盘弹出之后

预期结果:

正常弹出就行

实际结果:

页面能够滚动,但是其他的viv不会,目前安卓只发现了这个型号的会出现

bug描述:

textarea组件的adjust-position设置为false之后,键盘弹出之后页面能够进行滚动,目前vivo的手机只发现了这一个型号会出现这种情况,按理说键盘弹出页面能够滚动是ios的默认特性,为什么现在vivo的安卓也会影响到,而且已经设置了adjust-position为false了


更多关于uni-app textarea组件的adjust-position设置为false之后键盘弹出之后页面能够进行滚动的实战教程也可以访问 https://www.itying.com/category-93-b0.html

1 回复

更多关于uni-app textarea组件的adjust-position设置为false之后键盘弹出之后页面能够进行滚动的实战教程也可以访问 https://www.itying.com/category-93-b0.html


这是一个已知的Android兼容性问题,主要与vivo S30的键盘处理机制有关。

adjust-position="false" 在大多数Android设备上能正常工作,但部分vivo机型(特别是S30)的定制系统会忽略这个设置。这是因为:

  1. 系统级键盘处理差异:vivo的Funtouch OS对键盘弹出行为有额外的处理逻辑,可能覆盖了应用的设置
  2. Webview兼容性:不同机型的系统Webview版本和实现存在差异
  3. 键盘高度计算:S30的键盘高度计算方式可能导致页面布局异常

临时解决方案

// 监听键盘高度变化,强制固定页面位置
onKeyboardheightchange(e) {
    if (e.detail.height > 0) {
        // 键盘弹出时,通过CSS或JS固定页面滚动位置
        document.body.style.overflow = 'hidden';
    } else {
        document.body.style.overflow = '';
    }
}

或者使用@focus事件手动控制页面滚动行为:

onFocus() {
    // 记录当前滚动位置,并在需要时恢复
    this.scrollTop = document.documentElement.scrollTop;
    window.scrollTo(0, 0);
}
回到顶部