直接使用,无法通信
![2***@qq.com](https://img-cdn-tc.dcloud.net.cn/account/identicon/adc449006ad312c77de5dfa752394aa0.png)
- 发布:2024-12-22 17:10
- 更新:2024-12-23 09:19
- 阅读:77
产品分类: uniapp/小程序/字节跳动
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: windows
HBuilderX类型: 正式
HBuilderX版本号: 4.29
第三方开发者工具版本号: 4.3.3
基础库版本号: 3.49.0.7
项目创建方式: HBuilderX
操作步骤:
预期结果:
希望h5回调传值在小程序能收到
希望h5回调传值在小程序能收到
实际结果:
没有反应
没有反应
bug描述:
小程序页面代码如下
<template>
<web-view
ref="webview"
src="https://localhost"
@load="onWebLoad"
@message="onMessage"
@onPostMessage="getMessage"
@error="onError"
></web-view>
</template>
<script>
// import { mapActions, mapMutations } from "vuex";
export default {
name: "list",
data() {
return {};
},
onLoad() {
console.log(this.$ref);
},
methods: {
onWebLoad(params) {
console.log("onWebLoad", params);
},
onMessage(params) {
console.log("onMessage", params);
},
getMessage(params) {
console.log("getMessage", params);
},
onError(params) {
console.log("onError", params);
},
},
};
</script>
<style lang="scss" scoped></style>
以下是html代码
<body>
<div class="fileInputTips">
请上传PDF格式文件
</div>
<form id="uploadForm" enctype="multipart/form-data">
<div class="fileInputBtn">
<span id="upText">点击上传</span>
<input id="fileInput" accept=".pdf" class="fileInput" type="file" required>
</div>
<!-- <button class="fileInputBtn2" type="submit">提交文件</button> -->
<button class="fileInputBtn2" type="button" onclick="tijiao()">提交文件</button>
</form>
<!-- uni 的 SDK -->
<script type="text/javascript" src="./uni.webview.js"></script>
<script type="text/javascript">
function tijiao() {
//webUni是为了防止被uni覆盖改名的
webUni.postMessage({
data: {
action: 'message'
},
});
}
</script>
</body>
2***@qq.com (作者)
无效的,没有任何卵用
2024-12-26 23:06