State diagrams
2025/8/18小于 1 分钟
State diagrams
States
定义状态的三种方式:
- 直接定义状态名称:stateName
- state "description" as stateName
- stateName : description
Transitions
[!quote]
Transitions are path/edges when one state passes into another. This is represented using text arrow, "-->".
实现:
stateDiagram-v2
s1 --> s2: A transition效果:
Start and End
标识状态的起点和终点
实现:
stateDiagram-v2
[*]-->s1
s1-->[*][*]:如果它指向一个状态那么它就是该状态的起点,如果它被指向,那么就是终点。
效果:
Notes
对状态的补充说明
语法:
note <position> state
content
end noteposition:
- right of
- left of
实现:
stateDiagram-v2
s1-->s2
note right of s1
this is a note
end note效果:
Direction of diagram
默认的状态转换显示为从上至下,可以指定方向
实现:
stateDiagram-v2
direction LR
[*]-->A
A-->B
B-->[*]效果: