I created 2 Angular 16 projects, 1 host and 1 remote. I based my code on the MF Flight Tutorial
instead of having 1 Angular project I separated them into 2 projects the shell-ui (host) and the launch-ui (remote).
我创建了两个角度16项目,一个主机和一个远程。我的代码基于MF Flight教程,而不是一个角度项目,我将它们分成两个项目:Shell-UI(主机)和Launch-UI(远程)。
My problem is when I run both projects the launch-element does not load any data and it doesn't give me any errors. I also added the link to the React Version: ^17.0.1 from the FM tutorial and the data gets displayed.
我的问题是,当我同时运行这两个项目时,Launch-Element不会加载任何数据,也不会给我任何错误。我还添加了FM教程中REACT版本的链接:^17.0.1,数据就会显示出来。
Here is my route code (app.routes.ts) in the shell-ui project:
下面是我在shell-ui项目中的路由代码(app.routes.ts):
export const APP_ROUTES: Routes = [
{
path: '',
component: NotFoundComponent,
pathMatch: 'full',
},
{
path: 'launch',
component: WebComponentWrapper,
data: {
type: 'module',
remoteEntry:
'http://localhost:4202/remoteEntry.js',
remoteName: 'launch',
exposedModule: './launch',
elementName: 'launch-element',
} as WebComponentWrapperOptions,
},
{
path: 'react',
component: WebComponentWrapper,
data: {
type: 'script',
remoteEntry:
'https://witty-wave-0a695f710.azurestaticapps.net/remoteEntry.js',
remoteName: 'react',
exposedModule: './web-components',
elementName: 'react-element',
} as WebComponentWrapperOptions,
},
Here is my code in the launch-ui webpack.config.js file:
以下是我在Launch-UI webpack.config.js文件中的代码:
plugins: [
new ModuleFederationPlugin({
library: { type: "module" },
// For remotes (please adjust)
name: "launch",
filename: "remoteEntry.js",
exposes: {
'./launch': '/src/app/launch/launch.module.ts',
},
shared: share({
"@angular/core": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/common": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/common/http": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/router": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
...sharedMappings.getDescriptors()
})
}),
Here is a screenshot of the launch-element with no data:
下面是没有数据的launch-element的屏幕截图:
Here is a screenshot of the react-element with data:
以下是带数据的Reaction元素的屏幕截图:
I've also uploaded my code in Github
Github shell-ui
Github launch-ui
我还在Github Github shell-UI Github Launch-UI中上传了我的代码
更多回答
我是一名优秀的程序员,十分优秀!