uni-app 新版本HbuilderX 运行webview组件出现TypeError: this._onParentReady is not a function at view.umd.min.js:1
uni-app 新版本HbuilderX 运行webview组件出现TypeError: this._onParentReady is not a function at view.umd.min.js:1
测试过的手机
安卓手机 Honor 8X android10.0
苹果手机 Iphone6 Plus ios15.1
操作步骤
<web-view :src="url" :webview-styles="webviewStyles"></web-view>
预期结果
正常不报错
实际结果
TypeError: this._onParentReady is not a function at view.umd.min.js:1
bug描述
只要运行wenview组件就报错
TypeError: this._onParentReady is not a function at view.umd.min.js:1
webview代码
var currentWebview = this.$mp.page.$getAppWebview();
setTimeout(function() {
wv = currentWebview.children()[0]
wv.setStyle({bottom: 0})
}, 1000);
| 项目信息 | 详细信息 |
|---|---|
| 产品分类 | uniapp/App |
| PC开发环境操作系统 | Windows |
| PC开发环境操作系统版本号 | windows10 企业版 |
| HBuilderX类型 | Alpha |
| HBuilderX版本号 | 3.2.13 |
| 手机系统 | 全部 |
| 手机厂商 | 华为 |
| 页面类型 | vue |
| 打包方式 | 云端 |
| 项目创建方式 | HBuilderX |
更多关于uni-app 新版本HbuilderX 运行webview组件出现TypeError: this._onParentReady is not a function at view.umd.min.js:1的实战教程也可以访问 https://www.itying.com/category-93-b0.html
更多关于uni-app 新版本HbuilderX 运行webview组件出现TypeError: this._onParentReady is not a function at view.umd.min.js:1的实战教程也可以访问 https://www.itying.com/category-93-b0.html
好的
这个错误通常是由于新版HBuilderX中web-view组件内部实现变更导致的兼容性问题。_onParentReady是web-view组件内部方法,在新版本中可能已被移除或重构。
解决方案:
-
检查HBuilderX版本兼容性
- 3.2.13版本可能存在已知问题,建议升级到最新稳定版
- 或者回退到3.2.12等更稳定的版本
-
修改webview操作代码 将原有的webview操作代码改为以下方式:
// 使用uni.createWebViewContext API const webviewContext = uni.createWebViewContext('webview-id'); // 或者在mounted生命周期中操作 mounted() { setTimeout(() => { const pages = getCurrentPages(); const currentPage = pages[pages.length - 1]; const webview = currentPage.$getAppWebview(); if (webview && webview.children) { const wv = webview.children()[0]; if (wv && wv.setStyle) { wv.setStyle({bottom: 0}); } } }, 1000); } -
检查web-view组件使用方式
<web-view id="webview-id" :src="url" :webview-styles="webviewStyles" @message="onMessage" ></web-view> -
清理项目缓存
- 删除
unpackage、node_modules目录 - 清除HBuilderX缓存(菜单:运行->清理缓存)
- 重新安装依赖并运行
- 删除
-
临时解决方案 如果急需使用,可以在
manifest.json中配置使用旧版webview:{ "app-plus": { "webview": { "kernel": "WKWebView" } } }

