BindAttribute 元素绑定属性
1. 结构声明
- TS Declaration
- JSON Schema
class BindAttribute extends BaseNode {
name: string = '';
type?: 'string' | 'static' | 'dynamic';
value?: string | boolean | number;
expression?: LogicItem;
expressionExample?: string;
destination?: Destination;
externalDestination?: ExternalDestination;
rules?: Array<ValidationRule>;
assignee?: Assignee;
assigneeV2?: AssigneeV2;
model?: boolean;
sync?: boolean;
playground: Array<LogicItem>;
i18nKey?: uuid;
}
{
"type": "object",
"properties": {
"composedBy": {
"type": "array",
"items": {
"type": "string"
}
},
"changedTime": {
"$ref": "#/definitions/long"
},
"name": {
"type": "string"
},
"type": {
"type": "string",
"enum": [
"string",
"static",
"dynamic"
]
},
"value": {
"type": [
"string",
"boolean",
"number"
]
},
"expression": {
"$ref": "#/definitions/LogicItem"
},
"expressionExample": {
"type": "string"
},
"destination": {
"$ref": "#/definitions/Destination"
},
"externalDestination": {
"$ref": "#/definitions/ExternalDestination"
},
"rules": {
"type": "array",
"items": {
"$ref": "#/definitions/ValidationRule"
}
},
"assignee": {
"$ref": "#/definitions/Assignee"
},
"assigneeV2": {
"$ref": "#/definitions/AssigneeV2"
},
"model": {
"type": "boolean"
},
"sync": {
"type": "boolean"
},
"playground": {
"type": "array",
"items": {
"$ref": "#/definitions/LogicItem"
}
},
"i18nKey": {
"$ref": "#/definitions/uuid"
}
},
"required": [
"name",
"playground"
],
"additionalProperties": false
}
2. 节点示例
(1) 字符串属性
AST 如下:
- JSON
- YAML
{
"concept": "BindAttribute",
"name": "color",
"type": "string",
"value": "primary",
"playground": []
}
concept: BindAttribute
name: color
type: string
value: primary
playground: []
对应的代码如下:
- 文本化 NASL
- Natural TS
color = 'primary'
color: 'primary'
(2) 非字符串的静态类型属性
AST 如下:
- JSON
- YAML
{
"concept": "BindAttribute",
"name": "min",
"type": "static",
"value": "24",
"playground": []
}
concept: BindAttribute
name: min
type: static
value: "24"
playground: []
对应的代码如下:
- 文本化 NASL
- Natural TS
min = 24
min: 24
(3) 双向绑定属性
AST 如下:
- JSON
- YAML
{
"concept": "BindAttribute",
"name": "visible",
"type": "dynamic",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "modalVisible"
},
"rules": [],
"sync": true,
"playground": []
}
concept: BindAttribute
name: visible
type: dynamic
expression:
concept: Identifier
namespace: ""
name: modalVisible
rules: []
sync: true
playground: []
对应的代码如下:
- 文本化 NASL
- Natural TS
visible = modalVisible
visible: sync(modalVisible)