枭云
枭云
  • 发布:2024-11-08 17:31
  • 更新:2024-11-09 09:27
  • 阅读:288

【已解决】vue3项目打包成h5后,与uniapp开发的app项目做交互,提示TypeError: Cannot read property 'navigateBack' of undefined

分类:HBuilderX

测试发现(uniapp)vue2项目打包成h5后,可与uniapp开发的app项目正常传递数据;但(uniapp)vue3项目转成h5后,与uniapp开发的app(vue3)项目调用相关api会直接报错。

比如调用uni.webView.navigateBack()后报错:TypeError: Cannot read property 'navigateBack' of undefined

vue3打包生成的index.html文件配置如下:
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="/web/work/assets/uni.bd4a33f8.css">
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title>同声传译</title>
<!--preload-links-->
<!--app-context-->
<script type="module" crossorigin src="/web/work/assets/index-CF7zsC1G.js"></script>
<link rel="stylesheet" crossorigin href="/web/work/assets/index-CObtIVYn.css">
</head>
<body>
<div id="app"><!--app-html--></div>
<script src="uniwebview.js"></script>
</body>
</html>

2024-11-08 17:31 负责人:无 分享
已邀请:
枭云

枭云 (作者)

问题已解决

要回复问题请先登录注册