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

子应用的图片资源加载不出来 #36

Closed
826327700 opened this issue Aug 19, 2019 · 6 comments
Closed

子应用的图片资源加载不出来 #36

826327700 opened this issue Aug 19, 2019 · 6 comments

Comments

@826327700
Copy link

接入一个最简单的create-react-app起手模板,如下图:
Snipaste_2019-08-19_12-45-23

@howel52
Copy link
Collaborator

howel52 commented Aug 19, 2019

src 需要走 hostname + port 的绝对地址,需要改动一下 publicPath

这是由于你的 CRA 项目启在 xxx1 端口下,而 master 项目启在 xxx2 端口,在 master 里通过相对路径加载资源会导致端口号错误的问题

@kuitos
Copy link
Member

kuitos commented Aug 19, 2019

楼上正解,开发阶段需要配置一下 publicPath: hostname + port
推荐基于 umi-plugin-qiankun 来搭建应用可以少很多配置阶段的麻烦

@kuitos
Copy link
Member

kuitos commented Aug 28, 2019

@kuitos kuitos closed this as completed Aug 28, 2019
@gaorubin1990
Copy link

@kuitos 子应用用的一个,并且设置了__webpack_public_path__ = window.INJECTED_PUBLIC_PATH_BY_QIANKUN。用简单的webpack+react搭建的主应用没问题,umi搭建的主应用有子应用图片加载不出来。状态码200,preview是空的

@keunone
Copy link

keunone commented Jun 8, 2020

@kuitos 请问,子应用已经设置了__webpack_public_path__ = window.INJECTED_PUBLIC_PATH_BY_QIANKUN;而且在webpack中配置了publicPath,但是主应用加载的子应用依然不能正确显示cdn图片路径,如下图,请问你什么思考方向吗?
子应用入口文件:
入口文件

子应用webpack配置:
webpack

主应用中子应用加载图片路径:
路径显示

@sansecao
Copy link

sansecao commented Mar 3, 2022

@keunone请问问题解决了吗,我也遇到了相同的问题

szy1000 pushed a commit to szy1000/qiankun that referenced this issue Aug 18, 2022
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

6 participants