연구 설문조사: 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-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."]]],[]]