请求与响应 <RequestResponse />
左右两个代码窗:左边是发出的请求,右边是返回的响应,中间一条带标签的箭头,上面有光点从左跑到右。
Template and style descriptions are currently available in Chinese only.
- Group
- 技术 · 一次往返
- Component
RequestResponse·#request-response- Interaction
- 箭头和响应是一个 build 步骤;光点动画在减少动态效果和打印时关闭
Good for
- 讲一次 API 调用、SQL 语句和返回、协议往返
- 请求和响应都能用几行文本表示
Avoid when
- 有多次往返或多方参与:用 SessionSequence
- 只有命令和输出、没有“两端”之分:用 Terminal
Content limits
| 1 | label ≤ 10 字;file ≤ 20 个字符 |
| 2 | lines 2–9 行,每行 ≤ 36 个字符 |
| 3 | via ≤ 8 字 |
| 4 | note ≤ 50 字 |
Fields
| Field | Type | |
|---|---|---|
kicker · required | string | 标题上方的小节名,2–8 字 |
title · required | string | string[] | 页面标题;传数组可手动断行,每项一行 |
lead | string | 一到两句导语,≤ 60 字 |
source | string | 事实出处;页面上有任何数据或事实时必填 |
hint | ReactNode | 页眉中间的操作提示,可用 <kbd> |
request · required | { label, file?, lines } | 请求 |
response · required | { label, file?, lines } | 响应 |
via | string | 箭头下的标签 |
note | string | 下方的一句解读 |
Example
<RequestResponse kicker="一次往返" title="…" request={{ label: '客户端发送', lines: ['UPDATE …'] }} via="一次往返" response={{ label: '服务器返回', lines: ['UPDATE 1'] }} />