연구 설문조사: 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"
]
}
자바스크립트
Blockly.Blocks['example_label'] = {
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldLabel('a label'));
this.appendDummyInput()
.appendField('and another label');
}
};
appendField 함수는 FieldLabel
객체와 더 일반적으로 라벨을 만드는 문자열을 모두 허용합니다.
라벨 필드는 선택적 값과 선택적 CSS 클래스 문자열을 사용합니다.
둘 다 기본값은 빈 문자열입니다.
직렬화
라벨 필드는 직렬화할 수 없습니다.
라벨이 프로그래매틱 방식으로 변경되므로 직렬화하려면 직렬화 가능한 라벨 필드를 참고하세요.
검사기
라벨 필드는 수정할 수 없으므로 검사기를 지원하지 않습니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-25(UTC)
[null,null,["최종 업데이트: 2025-07-25(UTC)"],[[["\u003cp\u003eA label field displays text on a block and stores the same string as both its \u003ccode\u003evalue\u003c/code\u003e and \u003ccode\u003etext\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eLabel fields can be created using JSON by specifying message strings or by explicitly interpolating labels, though the latter is discouraged for translation reasons.\u003c/p\u003e\n"],["\u003cp\u003eIn JavaScript, label fields are created using \u003ccode\u003eBlockly.FieldLabel\u003c/code\u003e and appended to block inputs using \u003ccode\u003eappendField\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eWhile not serializable by default, a separate "Serializable Label" field exists for cases requiring programmatic changes and serialization.\u003c/p\u003e\n"],["\u003cp\u003eLabel fields do not support validators due to their non-editable nature.\u003c/p\u003e\n"]]],[],null,["# Label fields\n\nA label field stores a string as its `value` and a string as its `text`. The\n`value` and `text` of a label field are always the same.\n\n#### Label field\n\n#### Label field on collapsed block\n\nCreation\n--------\n\n### JSON\n\n {\n \"type\": \"example_label\",\n \"message0\": \"a label %1 and another label\",\n \"args0\": [\n {\n \"type\": \"input_dummy\"\n }\n ]\n }\n\nAny message text between interpolation arguments becomes label strings.\nAlternatively, labels may be interpolated explicitly, either as an object or\nas text. This is generally discouraged as it makes translation more\ndifficult. \n\n {\n \"type\": \"example_label\",\n \"message0\": \"%1 %2 %3\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"a label\"\n },\n {\n \"type\": \"input_dummy\"\n },\n \"and another label\"\n ]\n }\n\n### JavaScript\n\n Blockly.Blocks['example_label'] = {\n init: function() {\n this.appendDummyInput()\n .appendField(new Blockly.FieldLabel('a label'));\n this.appendDummyInput()\n .appendField('and another label');\n }\n };\n\nThe [appendField](/blockly/reference/js/Blockly.Input#appendField)\nfunction accepts both `FieldLabel` objects and, more commonly, strings to create\nlabels.\n\nThe label field takes in an optional value, and an optional css class string.\nBoth default to an empty string.\n\nSerialization\n-------------\n\nLabel fields are not serializable.\n\nIf you would like your label to be serialized, because it is being changed\nprogrammatically, see the [Serializable Label](/blockly/guides/create-custom-blocks/fields/built-in-fields/label-serializable)\nfield.\n\nValidators\n----------\n\nLabel fields do not support validators, because they are not editable."]]