Garfish 是字节跳动开源的微前端框架,旨在应对现代 Web 应用在前端生态繁荣与应用日益复杂化背景下的挑战。本文将介绍如何使用 Garfish,提供代码示例,并与另一流行的微前端框架 Qiankun 进行对比分析。
安装 Garfish
首先,安装 Garfish 核心库:
npm install @garfish/core --save
创建主应用
创建主应用的入口文件,如 index.js
或 main.js
,并初始化 Garfish:
import Garfish from '@garfish/core';
const garfish = new Garfish({
router: {
historyType: 'hash',
publicPath: '/',
routes: [
{
path: '/app1',