y***@sina.com
y***@sina.com
  • 发布:2020-05-20 14:31
  • 更新:2021-04-03 11:42
  • 阅读:998

【报Bug】输入框获取焦点后页面没有上移,而是被软键盘覆盖。

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

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

HBuilderX类型: 正式

HBuilderX版本号: 2.7.5

手机系统: Android

手机系统版本号: Android 10

手机厂商: 华为

手机机型: 荣耀20pro

页面类型: vue

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

            // 目前在某些平台参数会被主动 decode,暂时这样处理。  
            try {  
                this.item = JSON.parse(decodeURIComponent(options.query));  
            } catch (error) {  
                this.item = JSON.parse(options.query);  
            }  
            this.prid = this.item.prid;  

            console.log(this.item);  

            uni.setNavigationBarTitle({  
                title: this.item.title  
            });  

            console.log(this.prid);  
            this.src = this.$store.state.baseUrl + 'rest?id=' + this.prid;  
            console.log(">>>>> webview load success")  

            // #ifdef APP-PLUS  

            let wv = plus.webview.create("", "custom-webview", {  
                plusrequire: "none", //禁止远程网页使用plus的API,有些使用mui制作的网页可能会监听plus.key,造成关闭页面混乱,可以通过这种方式禁止  
                'uni-app': 'none', //不加载uni-app渲染层框架,避免样式冲突  
                top: uni.getSystemInfoSync().statusBarHeight + 44, //放置在titleNView下方。如果还想在webview上方加个地址栏的什么的,可以继续降低TOP值  
                bottom: 0,  
                softinputMode: 'adjustResize'  
            })  
)  
            var currentWebview = this.$scope.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效,非v3编译模式使用this.$mp.page.$getAppWebview()  
            currentWebview.append(wv); //一定要append到当前的页面里!!!才能跟随当前页面一起做动画,一起关闭  

            uni.onKeyboardHeightChange(function(res) {  
                console.log("键盘高度:" + res.height);  

                currentWebview.setStyle({  
                    bottom: res.height  
                });  
            })  

            // #endif  

操作步骤:

输入框获取焦点

预期结果:

页面被软件盘顶起来

实际结果:

输入框被覆盖了

bug描述:

  • 问题1:输入框获取焦点后页面没有上移,而是被软键盘覆盖。
  • 问题2:自定义的webview监听键盘高度事件,设置webview底部高度没生效。

上面两个问题在2.6.16.20200424 版本是正常的

2020-05-20 14:31 负责人:无 分享
已邀请:
终究会弄懂

终究会弄懂

我也出现这个问题

该问题目前已经被锁定, 无法添加新回复