uni-app textarea组件在安卓机型上未触发 @keyboardheightchange 方法

uni-app textarea组件在安卓机型上未触发 @keyboardheightchange 方法

开发环境 版本号 项目创建方式
Windows 10 HBuilderX
产品分类:uniapp/App

PC开发环境操作系统:Windows

PC开发环境操作系统版本号:10

HBuilderX类型:正式

HBuilderX版本号:3.1.2

手机系统:Android

手机系统版本号:Android 10

手机厂商:华为

手机机型:小米10

页面类型:vue

打包方式:云端

App下载地址或H5网址:[https://www.pgyer.com/phd9](https://www.pgyer.com/phd9)

### 示例代码:

```html
<textarea class="textarea" :show-confirm-bar="false"   :placeholder="placeholder" :auto-height="true"  
auto-focus="true" :focus="true" :hold-keyboard="true" :fixed="true" :adjust-position="false"
            [@keyboardheightchange](/user/keyboardheightchange)="onKeyboardHeightChange"  :maxlength="250" :disable-default-padding="true"></textarea>  

onKeyboardHeightChange(e){
consoloe.info("点击输入框");
},

操作步骤:

  • 点击输入框

预期结果:

  • 触发 onKeyboardHeightChange方法

实际结果:

  • 安卓 小米10 未触发 onKeyboardHeightChange方法

更多关于uni-app textarea组件在安卓机型上未触发 @keyboardheightchange 方法的实战教程也可以访问 https://www.itying.com/category-93-b0.html

4 回复

官方说 3.1.2.20210206 版本更新了这个问题,更新一下试试喽

更多关于uni-app textarea组件在安卓机型上未触发 @keyboardheightchange 方法的实战教程也可以访问 https://www.itying.com/category-93-b0.html


我就是这个版本的啊…

未复现您说的问题。

这是一个已知的uni-app在Android平台上的兼容性问题。keyboardheightchange事件在部分Android机型上可能无法正常触发。

解决方案建议:

  1. 可以尝试使用focusblur事件组合来间接监听键盘状态变化:
<textarea 
  @focus="handleFocus"
  @blur="handleBlur"
></textarea>
  1. 或者使用uni.onKeyboardHeightChange全局监听(HBuilderX 3.1.0+支持):
onLoad() {
  uni.onKeyboardHeightChange(res => {
    console.log('键盘高度变化:', res.height)
  })
}
回到顶部