Closed ljquan closed 1 month ago
描述bug 清晰准确的描述bug
如何复现 给出详细的复现步骤 1、第一步 修改示例代码 examples/vue3/src/views/Home.vue
<template> <div> <iframe src="http://localhost:7300/contact" ref="iframe"></iframe> <HelloWorld msg="Vue3示例"></HelloWorld> <div class="content" style="text-align: center"> <p> 当前vue版本 <el-tag style="vertical-align: text-top" size="small">3.2.24</el-tag> </p> <p> 当前element-plus版本 <el-tag style="vertical-align: text-top" size="small">2.2.6</el-tag> </p> <p> 当前ant-design-vue版本 <el-tag style="vertical-align: text-top" size="small">2.2.8</el-tag> </p> <p> <el-button @click="() => open('https://github.com/Tencent/wujie/tree/master/examples/vue3')" >仓库地址</el-button > </p> </div> </div> </template> <script setup> import HelloWorld from "@/components/HelloWorld.vue"; import {ref, onMounted} from 'vue'; const iframe = ref(); window.addEventListener('message', function(event) { console.log(event.origin, event.data); }); onMounted(()=>{ const iframeWindow = iframe.value.contentWindow; setInterval(()=>{ iframeWindow.postMessage('这是来自主页面的消息', 'http://localhost:7300'); }, 1E3); }) </script> <style> :root { --host-color: #f16b5f; } </style>
examples/vue3/src/views/Communication.vue
// script中添加代码 window.addEventListener('message', function(event) { console.log( event.origin, event.data); console.log('parent', parent) parent.postMessage('子页面的消息', '*'); });
2、 第二步 本地运行example,打开页面:http://localhost:8000/vue3?vue3=%2Fhome
错误截图 如果有可以将截图带上 过滤”子页面的消息'“,消息为空 直接打开子应用页面:http://localhost:7300/home 过滤”子页面的消息'“
最小复现仓库或者地址 重要!!!,请尽量给出复现仓库,这样能极大加快bug解决速度
可以看看示例,是可以正常通信的 https://wujie-micro.github.io/demo-main-vue/postmessage?vue2=%2Fdemo-vue2%2F%23%2Fpostmessage
描述bug 清晰准确的描述bug
如何复现 给出详细的复现步骤 1、第一步 修改示例代码 examples/vue3/src/views/Home.vue
examples/vue3/src/views/Communication.vue
2、 第二步 本地运行example,打开页面:http://localhost:8000/vue3?vue3=%2Fhome
错误截图 如果有可以将截图带上
过滤”子页面的消息'“,消息为空
直接打开子应用页面:http://localhost:7300/home
过滤”子页面的消息'“
![image](https://github.com/Tencent/wujie/assets/3754268/b79d4687-1e1f-4d4c-a66f-f0ca23ce71ec)
最小复现仓库或者地址 重要!!!,请尽量给出复现仓库,这样能极大加快bug解决速度