標籤欄位會將字串儲存為 value
,並將字串儲存為 text
。標籤欄位的 value
和 text
一律相同。
標籤欄位
收合區塊的標籤欄位
創作風潮
JSON
{
"type": "example_label",
"message0": "a label %1 and another label",
"args0": [
{
"type": "input_dummy"
}
]
}
內插引數之間的任何訊息文字都會變成標籤字串。或者,標籤也可以明確插入標籤,為物件或文字。一般而言,我們不建議這麼做,因為這樣會提高翻譯的難度。
{
"type": "example_label",
"message0": "%1 %2 %3",
"args0": [
{
"type": "field_label",
"text": "a label"
},
{
"type": "input_dummy"
},
"and another label"
]
}
JavaScript
Blockly.Blocks['example_label'] = {
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldLabel('a label'));
this.appendDummyInput()
.appendField('and another label');
}
};
appendField 函式可接受 FieldLabel
物件,以及更常見的字串來建立標籤。
標籤欄位接受選用值,以及選用的 css 類別字串。兩者均預設為空白字串。
序列化
標籤欄位無法序列化。
如果您因為要以程式輔助方式變更標籤,而希望該標籤能夠序列化,請參閱「序列化標籤」欄位。
驗證工具
標籤欄位不支援驗證工具,因此無法支援驗證工具。