Skip to Content
微前端设计与实现
book

微前端设计与实现

by Luca Mezzalira
August 2022
Beginner to intermediate
270 pages
7h 38m
Chinese
Posts & Telecom Press
Content preview from 微前端设计与实现
探索微前端架构
33
微前端决策框架可以帮助你确定应用项目的最佳架构。
4.1.1
 纵向拆分
经常写单页应用的前端工程师都知道,纵向拆分提供不了太多选择,正如图
4-1
中客户端
所采用的拆分方案一样。当项目需要持续一致的用户界面变化和跨页面的流畅的用户体验
时,纵向拆分就显得非常有用。因为对于单页应用来说,纵向拆分方式的开发体验最为契
合,所以与单页应用相关的工具、最佳实践和模式都可用于微前端开发。
尽管你从技术上可以使用任意组合方式实现一个纵向拆分的微前端,但目前纵向拆分的客
户端组合都在
App shell
内加载、卸载微前端,并且只应用这一种组合方式。微前端和
App
shell
之间的关系是一对一的
,也就是说,
App shell
一次只加载一个微前端。当然也有例
外,你可以使用客户端路由来集成多个微前端,即在
App shell
中利用一个全局路由来加载
不同的微前端,如图
4-2
所示。
认证微前端 目录微前端 客户支持微前端
App shell
/signup /catalog /help
4-2App shell 负责微前端之间的全局路由
虽然在同一个微前端内部的局部路由是由微前端自身控制的(图
4-3
),但你可以完全掌控
微前端内部视图的实现和演进,因为负责一个微前端的团队同时是该应用所在业务领域的
专家。
最后,为了实现一个采用纵向拆分的微前端架构,
App shell
加载
HTML
文件或者
JavaScript
文件作为应用的入口,不应该与其他的微前端共享任何业务逻辑,且不限制微前端使用的
技术栈。为了满足未来的系统演进,不应该使用特定的前端框架实现 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Python语言及其应用(第2版)

Python语言及其应用(第2版)

Bill Lubanovic

Publisher Resources

ISBN: 9787115595089