فیلدهای برچسب
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
یک فیلد برچسب یک رشته را به عنوان 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 اختیاری می گیرد. هر دو به طور پیش فرض یک رشته خالی هستند.
سریال سازی
فیلدهای برچسب قابل سریال سازی نیستند.
اگر میخواهید برچسب شما سریالی شود، زیرا به صورت برنامهنویسی در حال تغییر است، به قسمت Serializable Label مراجعه کنید.
اعتبار سنجی ها
فیلدهای برچسب از اعتبار سنجی پشتیبانی نمی کنند، زیرا قابل ویرایش نیستند.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\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."]]