Skip to content

Conversation

@loycoder
Copy link

@loycoder loycoder commented Dec 25, 2023

  • ✅ 提交符合commit规范
  • ✅ 测试用例添加
  • npm run test通过
详细描述

问题描述:
在子应用中,如果出现iframe 场景,使用的postmessage传递消息, 会出现事件派发到基座的 window,而并非子应用的window
image

原因:
patchIframeEvents 中对 iframe 事件的处理,当未指定 options.targetWindow 时,使用的是iframeWindow, 应该优先使用window.WUJIE_RAW_WINDOW
image

@yiludege
Copy link
Collaborator

yiludege commented Jan 2, 2024

patchIframeEvents 中对 iframe 事件的处理,当未指定 options.targetWindow 时,使用的是iframeWindow, 应该优先使用window.WUJIE_RAW_WINDOW

这个地方感觉有问题呢,子应用window监听为啥不绑子应用的iframewindow,如果采用window.WUJIE_RAW_WINDOW,意味着绑定的是主应用的window哦

@yumanman88
Copy link

子应用使用window.WUJIE_RAW_WINDOW监听message,子应用内嵌的iframe发送信息时应该怎么取target呢

@cxl623
Copy link

cxl623 commented Jan 11, 2024

好像拿到的window还是无界项目的啊

@yiludege
Copy link
Collaborator

子应用使用window.WUJIE_RAW_WINDOW监听message,子应用内嵌的iframe发送信息时应该怎么取target呢

postmessage 的使用已经在demo更新了

@yiludege yiludege added the invalid This doesn't seem right label Nov 24, 2024
@surebye
Copy link

surebye commented Jun 14, 2025

完全就没解决问题,我项目主应用会多次实例化子应用,子应用也会多次实例化iframe,如果由主应用来分发事件,根本无法解决这个消息是哪个子应用的的哪个iframe触发的,导致一个事件,全部都执行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants