{"id":18952720,"url":"https://github.com/337547038/vue-single-spa","last_synced_at":"2026-03-29T12:30:22.277Z","repository":{"id":39011698,"uuid":"261716129","full_name":"337547038/vue-single-spa","owner":"337547038","description":"从零搭建vue single-spa微前端服务","archived":false,"fork":false,"pushed_at":"2023-01-06T17:13:43.000Z","size":2126,"stargazers_count":0,"open_issues_count":48,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-01T02:41:42.955Z","etag":null,"topics":["single-spa"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/337547038.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-06T09:45:56.000Z","updated_at":"2020-05-06T09:48:13.000Z","dependencies_parsed_at":"2023-02-06T07:01:29.373Z","dependency_job_id":null,"html_url":"https://github.com/337547038/vue-single-spa","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/337547038%2Fvue-single-spa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/337547038%2Fvue-single-spa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/337547038%2Fvue-single-spa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/337547038%2Fvue-single-spa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/337547038","download_url":"https://codeload.github.com/337547038/vue-single-spa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239952598,"owners_count":19723922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["single-spa"],"created_at":"2024-11-08T13:34:26.783Z","updated_at":"2026-03-29T12:30:22.236Z","avatar_url":"https://github.com/337547038.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vue single-spa 改造\n\n## 父项目\n   1、安装`npm install single-spa --save`\n   \n   2、新建`single-spa-config.js`并在`main.js`中引入\n   \n   3、`App.vue`中添加标识，用于引入子项目`\u003cdiv id=\"vue\"\u003e\u003c/div\u003e`\n   \n   4、父项目404问题，添加一个路由指向 \n   ```txt\n   {\n       path: '/vueApp1*', // 包含子路由\n     },\n   ```\n   \n### 子项目\n  1、`vue.config.js`添加如果设置  \n  ```txt\n  {\n  publicPath: \"//localhost:8095/vueApp1/\", // 对应父项目startsWith('/vueApp1')\n  configureWebpack: {\n      devtool: 'none', // 不打包sourcemap\n      output: {\n        library: 'singleVue', // 导出名称\n        libraryTarget: 'window' // 挂载目标\n      },\n      plugins: [\n        new StatsPlugin('manifest.json', {\n          chunkModules: false,\n          entrypoints: true,\n          source: false,\n          chunks: false,\n          modules: false,\n          assets: false,\n          children: false,\n          exclude: [/node_modules/]\n        })\n      ]\n    },\n    devServer: {\n      contentBase: './',\n      compress: true,\n      headers: {'Access-Control-Allow-Origin': '*'}\n    }\n    }\n  ``` \n\n  2、安装 `npm install single-spa-vue --save` `npm install stats-webpack-plugin --save`\n  \n  3、改写main.js\n  ```txt\n  const vueOptions = {\n    el: \"#vue\",\n    router,\n    store,\n    render: h =\u003e h(App)\n  };\n  \n  // 判断当前页面使用singleSpa应用,不是就渲染\n  if (!window.singleSpaNavigate) {\n    delete vueOptions.el;\n    new Vue(vueOptions).$mount('#app');\n  }\n  \n  \n  // singleSpaVue包装一个vue微前端服务对象\n  const vueLifecycles = singleSpaVue({\n    Vue,\n    appOptions: vueOptions\n  });\n  \n  export const bootstrap = vueLifecycles.bootstrap; // 启动时\n  export const mount = vueLifecycles.mount; // 挂载时\n  export const unmount = vueLifecycles.unmount; // 卸载时\n  \n  export default vueLifecycles;\n  ```\n  \n4、修改路由`base:'/vueApp1'`,对应父项目`startsWith('/vueApp1')`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F337547038%2Fvue-single-spa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F337547038%2Fvue-single-spa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F337547038%2Fvue-single-spa/lists"}