調査アンケート: Blockly のご利用体験についてお聞かせください
アンケートを開始
ラベルのフィールド
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
ラベルフィールドは、文字列を 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 クラス文字列を指定します。どちらもデフォルトは空の文字列です。
シリアル化
ラベルフィールドはシリアル化できません。
ラベルがプログラムで変更されるためシリアル化する場合、[シリアル化可能ラベル] フィールドをご覧ください。
バリデータ
ラベル フィールドは編集できないため、バリデータをサポートしていません。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-06-17 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-06-17 UTC。"],[[["A label field displays text on a block and stores the same string as both its `value` and `text`."],["Label fields can be created using JSON by specifying message strings or by explicitly interpolating labels, though the latter is discouraged for translation reasons."],["In JavaScript, label fields are created using `Blockly.FieldLabel` and appended to block inputs using `appendField`."],["While not serializable by default, a separate \"Serializable Label\" field exists for cases requiring programmatic changes and serialization."],["Label fields do not support validators due to their non-editable nature."]]],[]]