特性: 添加对 erDiagram 中方向的支持

作者: Vahor创建于 2026年6月22日更新于 2026年8月29日

https://mermaid.ai/open-source/syntax/entityRelationshipDiagram.html 可以看到,我们可以在 erDiagram 中使用 direction [方向]。但是如果我使用他们的示例文档:

erDiagram
    direction TB
    CUSTOMER ||--o{ ORDER : places
    CUSTOMER {
        string name
        string custNumber
        string sector
    }
    ORDER ||--|{ LINE-ITEM : contains
    ORDER {
        int orderNumber
        string deliveryAddress
    }
    LINE-ITEM {
        string productCode
        int quantity
        float pricePerUnit
    }

预期的结果应该是类似于:

Image

但是我们得到的结果是:

Image

是否有办法使用方向?

内容来源: lukilabs/beautiful-mermaid