@startuml participant Alice as A participant Bob as B participant Carol as C
Note over A: 用户登录 Note left of A: 发起认证请求 A -> B: POST /login\n{username, password} Note right of B: 验证凭证 B --> A: 200 OK\n{token} Note over A,B: 登录成功 Note over C: Carol 旁观\n不参与此流程 @enduml
Mermaid 版
1 2 3 4 5 6 7 8 9 10 11 12
sequenceDiagram participant A as Alice participant B as Bob participant C as Carol
Note over A: 用户登录 Note left of A: 发起认证请求 A->>+B: POST /login<br/>{username, password} Note right of B: 验证凭证 B-->>-A: 200 OK<br/>{token} Note over A,B: 登录成功 Note over C: Carol 旁观<br/>不参与此流程
对比 / Side-by-side
特性
PlantUML
Mermaid
左侧 Note
Note left of <participant>
Note left of <participant>
右侧 Note
Note right of <participant>
Note right of <participant>
跨越多参与者
Note over <p1,p2>
Note over <p1,p2>
跨越范围写法
Note over <p1> 仅单方
Note over <p1> 仅单方
多行文本
直接换行,\n 可选
<br/> 换行
小结 / Wrap-up
PlantUML 的 Note 语法更简洁,Note left/right of 与 Note over 分工明确,适合复杂场景。Mermaid 的 Note 语法与消息语法一致,学习成本低,但需要用 <br/> 显式换行。两者均支持跨越多个参与者的 Note,用于描述跨对象共享的状态或上下文。