Skip to content

2.顺序图

基本使用

text
@startuml
App -> Backend: 登录Authentication Request
Backend --> App: Authentication Response
@enduml
@startuml
App -> Backend: 登录Authentication Request
Backend --> App: Authentication Response
@enduml

展示效果如图:

uml diagram

可以看到:
->为实线箭头
-->为虚线箭头

高级用法

默认参与者为participant,支持其他参与者:

  • actor(角色)
  • boundary(边界)
  • control(控制)
  • entity(实体)
  • database(数据库)
  • collections(集合)
  • queue(队列)

可使用as对角色重命名:
可使用#修改颜色
可使用order对参与者顺序进行调整, 例如order 1000

text
@startuml
participant Participant as Foo  order 1000
actor       Actor       as Foo1 #red
boundary    Boundary    as Foo2 #blue
control     Control     as Foo3
entity      Entity      as Foo4
database    Database    as Foo5
collections Collections as Foo6
queue       Queue       as Foo7
Foo -> Foo1 : To actor 
Foo -> Foo2 : To boundary
note right : You can also put notes!
Foo -> Foo3 : To control
Foo -> Foo4 : To entity
Foo -> Foo5 : To database
Foo -> Foo6 : To collections
Foo -> Foo7: To queue
@enduml
@startuml
participant Participant as Foo  order 1000
actor       Actor       as Foo1 #red
boundary    Boundary    as Foo2 #blue
control     Control     as Foo3
entity      Entity      as Foo4
database    Database    as Foo5
collections Collections as Foo6
queue       Queue       as Foo7
Foo -> Foo1 : To actor 
Foo -> Foo2 : To boundary
note right : You can also put notes!
Foo -> Foo3 : To control
Foo -> Foo4 : To entity
Foo -> Foo5 : To database
Foo -> Foo6 : To collections
Foo -> Foo7: To queue
@enduml

显示效果如下:

uml diagram