跳到正文
Skillpedia
网站与界面(前端)17k · #10799

qiankun

它能做什么

这个技能说明如何使用 qiankun 构建主应用,以及在运行时加载到主应用中的较小子应用。适合希望将大型前端拆分为多个部分的网页开发者。

适用场景

  • ✓当你想创建一个主应用,用来加载多个独立的前端应用时。
  • ✓当你想把现有的 Vite 应用改造为微子应用时。
  • ✓当你使用 React 或 Vue 设置微前端加载时。

技能链接

https://github.com/umijs/qiankun/blob/next/skills/qiankun/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/umijs/qiankun/blob/next/skills/qiankun/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我把现有的 Vite React 应用改造成一个 qiankun 子应用,让主应用外壳可以加载它。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会阅读与任务相符的指南,然后按照主应用或子应用的步骤操作。它会使用固定端口和匹配的应用名称,让各部分之间能够相互找到。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

qiankun

qiankun is a micro-frontend framework: a main (host) app loads sub (micro) apps from their HTML entries at runtime, each inside a JS sandbox, with opt-in CSS isolation. This skill is the agent-facing manual for qiankun 3.x.

Task routing

Read only the reference file(s) the task at hand needs:

Task Read
Create a micro (sub) app, or convert an existing Vite app references/create-micro-app.md
Create a main (host) app references/create-main-app.md
Anything else — migration, style isolation, sandbox, debugging https://qiankun.umijs.org and examples/ in https://github.com/umijs/qiankun

Before you start

Determine these, asking the user only when not inferable from context:

  1. App type — main (host/shell) or sub (micro app).
  2. App name — lowercase letters, numbers, hyphens. The name the host registers must exactly match the name the sub app uses in its classic-mode fallback.
  3. Framework — React or Vue; TypeScript or JavaScript. Templates in the references are TS; strip types for JS.
  4. Dev port — must be fixed and unique per app, because the host hard-references it in entry. Convention: main app 7099, sub apps 7101, 7102, …

Package versions — until qiankun 3.0 stable ships, rc is the dist-tag for the core packages:

Package Dist-tag Goes in
qiankun rc main app dependencies
@qiankunjs/react / @qiankunjs/vue rc main app dependencies (optional UI binding)
@qiankunjs/bundler-plugin rc sub app devDependencies

Key facts

These invariants shape every task below:

  • Vite sub apps need no dedicated build mode. qiankun 3 loads <script type="module"> natively through its ESM sandbox — regular vite dev / vite build output is qiankun-ready as-is.
  • The JS sandbox is on by default. CSS isolation is opt-in per app via styleIsolation: true (runtime CSS @scope).
  • A sub app must stay runnable standalone: when not loaded by qiankun (window.__POWERED_BY_QIANKUN__ is undefined) it renders itself directly.
  • Always unmount what you mount. loadMicroApp returns a handle whose .unmount() must be called when the app leaves; the MicroApp component bindings do this automatically on component unmount. Unmounted instances stay cached for reuse by app name; only .unload() / unloadMicroApp(name) releases them, and the bindings never call those.
  • Webpack sub apps use @qiankunjs/bundler-plugin/webpack instead of the Vite plugin; see the docs.

After any creation task

Verify the result following the checklist at the end of the reference you used. If a browser tool is available, perform the checks yourself instead of asking the user to.

常见问题

它涵盖哪个版本?

它是 qiankun 3.x 的手册,并说明在 3.0 正式版发布之前,部分核心包使用 rc 标签。

它同时支持 Vue 和 React 吗?

支持。该技能同时涵盖 React 和 Vue,其模板使用 TypeScript 编写。

迁移或调试怎么办?

对于创建主应用和子应用之外的主题,该技能会指向 qiankun 官方网站和示例。

详情

作者的原始描述

Usage manual for building micro-frontend projects with qiankun 3.x. Use when the user wants to create a qiankun main (host) app or sub (micro) app, convert an existing Vite app into a qiankun micro app, or wire up micro-frontend loading with React/Vue.

repo: umijs/qiankun

热度

GitHub 星标
17k
排名
#10799
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

相似技能