- qiankun主应用加载子应用时,url指定了localhost
const getEntry = (base: string, port: number) => {
const host: string = location.hostname
return process.env.NODE_ENV === 'development'
? `http://${host}:${port}${base}`
: `${base}/index.html`
}
而getEntry是用于qiankun子应用的加载配置
export const qiankun = {
apps: apps.map(app => {
if (app.name === 'distributed-storage') {
return {
name: app.name,
entry: `/distributed-storage-ui/`,
activeRule: `/distributed-storage`
}
}
return {
name: app.name,
entry: getEntry(`/${app.name}`, app.port)
}
}),
routes: appRoutes,
lifeCycles: {
afterMount: () => {}
},
prefetch: !isDev
}
需要将 getEntry 里面的 host 赋值成location.hostname,修改完成之后在远程可以打开。且功能完善,
此时完成了第一步,但是打开子应用会出现d