Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

子应用嵌套iframe ,iframe内部的 window.parent 指向到了主应用,并非子应用。 #773

Closed
loycoder opened this issue Dec 24, 2023 · 5 comments

Comments

@loycoder
Copy link

loycoder commented Dec 24, 2023

描述bug
子应用嵌套iframe ,iframe内部的 window.parent 指向到了主应用,并非子应用。子应用无法监听到 iframe发出的message.

如何复现

// 子应用:
window.addEventListener('message', receiveMessage);
  }, '*');
// 子应用下的iframe :
 window.parent.postMessage({
    eventName,
    data

wujie版本: 1.0.22
react版本: 18.0.0

错误截图
无错误.

最小复现仓库或者地址
在官方的examples 就能复现

@loycoder
Copy link
Author

loycoder commented Jan 2, 2024

已修复,着急使用的同学可以参考下代码: #775

@yumanman88
Copy link

请问这个修复发版本了嘛

@yiludege
Copy link
Collaborator

yiludege commented Jun 7, 2024

@yiludege yiludege closed this as completed Jun 7, 2024
@wenkeShi
Copy link

wenkeShi commented Jul 9, 2024

可以看看示例:https://wujie-micro.github.io/demo-main-vue/postmessage?vue2=%2Fdemo-vue2%2F%23%2Fpostmessage

@yiludege 一定要在父应用转发子应用的iframe message给子应用吗?为啥子应用里的iframe的window.parent不是子应用而是父应用?感觉不合理。

@yongdong1997
Copy link

可以看看示例:https://wujie-micro.github.io/demo-main-vue/postmessage?vue2=%2Fdemo-vue2%2F%23%2Fpostmessage

@yiludege 一定要在父应用转发子应用的iframe message给子应用吗?为啥子应用里的iframe的window.parent不是子应用而是父应用?感觉不合理。

确实,我在兼容老项目的时候有个子应用里面用到了弹窗通过iframe渲染一个公共选择器,原来选择器是通过window.parent调用父窗口的方法来返回结果的,现在postMessage只能在主应用接收,假如我渲染了很多个子应用我根本不知道转发给哪个子应用。也不清楚是哪个子应用打开的弹窗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants