qiankun框架子应用静态文件地址问题 #2134
Unanswered
zxf772330927
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
我是使用vue框架做的项目,主应用和子应用都是。
子应用(:8888)写法
http://localhost:8888/img/upLodimage.73f73008.png 是可以访问到图片的。
但是主应用(:5555)访问的时候,解析出来的html代码依然是
,对于页面来说这里的地址就是http://localhost:5555/img/upLodimage.73f73008.png了,访问失败。
当然,less里引入是ok的 background: url(“@/assets/images/uplod/upLodimage.png”);,虽然是相对路径,但是访问的时候,主应用和子应用访问的图片地址都是 http://localhost:8888/img/upLodimage.73f73008.png。
还有就是如果我这个项目中这个图片只引用了一次的时候这个图片是能正常访问的,如果这个图片被其他多个页面引用就会出现这个错误。
子应用代码:
![]()
import image from "@/assets/images/uplod/upLodimage.png";
data() {image}
config配置
const path = require("path");
const resolve = dir => {
return path.join(__dirname, dir);
};
const BASE_URL = process.env.NODE_ENV === "production" ? "./" : "/";
module.exports = {
publicPath: BASE_URL,
chainWebpack: config => {
config.resolve.alias
.set("@", resolve("src"))
.set("_c", resolve("src/components"))
},
configureWebpack: {
resolve: {
alias: {
vue$: "vue/dist/vue.esm.js",
"@": resolve("src"),
_c: resolve("src/components")
}
},
output: {
library: "pcMenu",
libraryTarget: "umd" // 把微应用打包成 umd 库格式
}
}
}
Beta Was this translation helpful? Give feedback.
All reactions