我是反应新手..我有反应应用程序,我已将其迁移到 Single-SPA。为了将我的应用程序与主应用程序(具有许多 Vue single-spa 应用程序的平台)集成,我将其重新构造为
MainApp - 它包括与进程相关的所有页面 - 在 localhost:3000 下运行
root-html-file - 它包括一个index.html和package.json文件index.html(在localhost:5000下运行-由SPA生成)
代码: root-html-file -> index.html
<script type="systemjs-importmap">
{
"imports": {
"myapp": "http://localhost:3000/",
"single-spa": "https://cdnjs.cloudflare.com/ajax/libs/single-spa/4.3.7/system/single-spa.min.js",
"react": "https://cdnjs.cloudflare.com/ajax/libs/react/16.8.6/umd/react.development.js"
}}</script>
Promise.all([System.import('single-spa'),System.import('react')]).then(function (modules) {
var singleSpa = modules[0];
singleSpa.registerApplication(
'myapp',
() => System.import('myapp'),
location => true
);
singleSpa.start();
Run Code Online (Sandbox Code Playgroud)
myapp 应用程序作为独立的工作正常。仅当运行 root-html-file 应用程序(npm runserve)时,该应用程序会将 myapp 应用程序加载到其中,从而导致 CROS origin 问题。请查看屏幕截图

如果我方向错误,请指导我。