测试发现(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>
1 个回复
枭云 (作者)
问题已解决