直观理解
想象一下,你的页面结构是这样的:
graph TB
Layout[Layout 布局]
Sidebar[Sidebar 侧边栏]
Page[Page 页面]
Profile[UserProfile 用户信息]
Layout --> Sidebar
Layout --> Page
Page --> Profile
Layout -.需要用户信息.-> API[getCurrentUser]
Sidebar -.需要用户信息.-> API
Page -.需要用户信息.-> API
Profile -.需要用户信息.-> API
style API fill:#f99,stroke:#333,stroke-width:2px
这 4 个组件都需要获取"当前用户信息",你可能会写 4 次 await getCurrentUser()。