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

子应用的百度地图加载后无法正常显示图层,独立运行没有问题 #195

Closed
xu90 opened this issue Sep 29, 2022 · 15 comments

Comments

@xu90
Copy link

xu90 commented Sep 29, 2022

通过Wujie接入子应用后,子应用的百度地图无法正常显示。具体表现为:
1、图层无法正常显示;
2、图层点击脚本异常

能正常搜索地点,且主应用、子应用同域,不存在跨域行为。像是canvas描画异常?

嵌入主应用的异常图示:
image

子应用独立运行无异常:
image

各位老师,还请看看是否有解决方案。[抱拳][抱拳]

@yiludege
Copy link
Collaborator

yiludege commented Sep 29, 2022

感觉是你这个百度地图还有 js 文件加载失败啊,跨域问题?

试试用 js-ignores

@xu90
Copy link
Author

xu90 commented Sep 29, 2022

感觉是你这个百度地图还有 js 文件加载失败啊,跨域问题?

试试用 js-ignores

子应用和主应用是同域的,也设置了 jsIgnores: [/baidu/]

@yiludege
Copy link
Collaborator

js 文件都没有加载成功的话地图出不来也正常,需要排查一下为什么 js 文件加载不出来

@xu90
Copy link
Author

xu90 commented Sep 29, 2022

有没有一种可是这些异步加载的JS像是作为地图的数据来源(script加载完毕后读取内容),但是嵌入主应用后 JS被转移到iframe处理导致?

在主应用嵌入后,会出现相同的请求(失败+成功各一次,成功的在iframe中
image

子应用单独运行查看network的js加载JS信息:
image

@yiludege
Copy link
Collaborator

有没有一种可是这些异步加载的JS像是作为地图的数据来源(script加载完毕后读取内容),但是嵌入主应用后 JS被转移到iframe处理导致?

嵌入主应用后JS确实是被转移到iframe里面了,在 iframe 里面的成功了应该就OK啊

@yiludege
Copy link
Collaborator

很想调试一下这个问题,但是又没有环境

@xu90
Copy link
Author

xu90 commented Sep 30, 2022

主要也不太方便提供demo。但是我这边调试了下,在wujie劫持后,确实也会执行script的load方法。

iframe劫持后在执行load,正常获取到script节点,但其父节点获取为null导致。调试的图示:

wujie劫持:
image

执行load:
image

script的parentNode为null:
image

@yiludege
Copy link
Collaborator

这个地方已经在 #188 修复了,看看今天能否发版出来

@xu90
Copy link
Author

xu90 commented Oct 8, 2022

更新至rc.20版本,首次打开子应用脚本无异常,但是地图还是无法显示,通过断点定位后看了下,并未正常执行load方法

添加load监听:
image

进入effect.js的rewriteAppendOrInsertChild方法:
image

进入iframe.js的insertScriptToIframe方法,执行append:
image

但无法进入下图中的load监听方法,导致地图无法正常绘制:
image

是否是因load事件添加的对象,与iframe中加载的对象不同,导致load的监听事件无法正常执行?

@wang8254
Copy link

wang8254 commented Oct 9, 2022

在考察是否用无界时,正好看到了这个问题,说一下我用micro-app遇到得加载地图得问题,在我使用micro-app时也出现了地图js加载不成功报跨域得问题,解决方式是在主应用中加载地图得相关api,问题得以解决。不知道是否提供了有用得思路,这只是个人见解

@xu90
Copy link
Author

xu90 commented Oct 9, 2022

在考察是否用无界时,正好看到了这个问题,说一下我用micro-app遇到得加载地图得问题,在我使用micro-app时也出现了地图js加载不成功报跨域得问题,解决方式是在主应用中加载地图得相关api,问题得以解决。不知道是否提供了有用得思路,这只是个人见解

我的主应用和子应用是同域的,理应不存在跨域问题,目前是加载后未执行绑定的load方法。主应用加载地图相关api的话,在子应用调整地图key,又或者多个子应用接的是不同的地图服务时,老师这边是怎么处理呢?

@yiludege
Copy link
Collaborator

是否是因load事件添加的对象,与iframe中加载的对象不同,导致load的监听事件无法正常执行?

发现确实有 bug,我这边修改一下

@yiludege
Copy link
Collaborator

已经发版 #87

@manwuyu
Copy link

manwuyu commented Oct 13, 2022

@yiludege 这个问题感觉并没有完全解决,
demo: https://github.com/manwuyu/wujieIssues1

@yiludege
Copy link
Collaborator

已经完全解决,详见:#215 (comment)

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

4 participants