Skip to main content
Version: 3.6

Enum 枚举

1. 结构声明

class Enum extends BaseNode {
name: string = '';
label: string;
description: string;
enumItems: Array<EnumItem>;
}

2. 节点示例

(1) 示例

AST 如下:

{
"concept": "Enum",
"name": "ProductStatus",
"label": "",
"description": "",
"enumItems": [
{
"concept": "EnumItem",
"value": "Listing",
"label": "上架"
},
{
"concept": "EnumItem",
"value": "Delisting",
"label": "下架"
}
]
}

对应的代码如下:

@(
label = "",
description = "",
)
enum ProductStatus {
@(label = "上架")
Listing

@(label = "下架")
Delisting
}

(2) 带描述的示例

AST 如下:

{
"concept": "Enum",
"name": "ProductStatus",
"label": "商品状态",
"description": "表示商品状态的枚举",
"enumItems": [
{
"concept": "EnumItem",
"value": "Listing",
"label": "上架"
},
{
"concept": "EnumItem",
"value": "Delisting",
"label": "下架"
}
]
}

对应的代码如下:

@(
label = "商品状态",
description = "表示商品状态的枚举",
)
enum ProductStatus {
@(label = "上架")
Listing

@(label = "下架")
Delisting
}