1. 参考文档
2. 主要代码:
h5端的:
需要的资源已经上传绑定了;
<template>
<div @click="handleSend" id="wq">发送信息</div>
</template>
import '../../utils/uni.webview.js';
// 点击发送方法 理论上也是可以使用uniapp的页面跳转api方法
const handleSend = () => {
console.log('传递数据', window);
uni.postMessage(
{
data: {
name: 'wq',
},
},
'*',
);
};
(uniapp) app端
<template>
<!-- 仅仅是测试 -->
<web-view :src="linkUrl" @message="onMessage"></web-view>
</template>
<script setup>
import { ref } from 'vue';
defineOptions({
name: 'testWeb',
});
const linkUrl = ref(
`https://testmicroh5.xihuxia.com?timestamp=${new Date().getTime()}/#/bSideMeeting`,
);
const onMessage = (event) => {
console.log('接收的信息', event);
};
</script>
<style scoped lang="scss"></style>