แบบสำรวจการวิจัย: บอกให้เราทราบเกี่ยวกับประสบการณ์การใช้งาน Blockly
เริ่มแบบสำรวจ
ช่องป้ายกำกับแบบเรียงลำดับได้
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ป้ายกำกับที่แปลงเป็นอนุกรมได้จะทำงานเหมือนกับป้ายกำกับปกติทุกประการ ยกเว้นว่าจะแปลงเป็นอนุกรม XML ด้วย คุณควรใช้แอตทริบิวต์นี้เฉพาะในกรณีที่คุณแก้ไขเนื้อหาของป้ายกำกับแบบเป็นโปรแกรม และต้องการให้จัดรูปแบบเป็น XML
ฟิลด์ป้ายกำกับที่ serialize ได้

ช่องป้ายกำกับที่ serialize ได้บนบล็อกแบบยุบ

การสร้างวิดีโอ
JSON
{
"type": "example_serializable_label",
"message0": "%1",
"args0": [
{
"type": "field_label_serializable",
"name": "FIELDNAME",
"text": "a serializable label"
}
]
}
JavaScript
Blockly.Blocks['example_serializable_label'] = {
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldLabelSerializable("a serializable label"), "FIELDNAME");
}
};
ช่องป้ายกำกับที่ serialize ได้จะรับค่าที่ไม่บังคับและสตริง css
class ที่ไม่บังคับ โดยค่าเริ่มต้นจะเป็นสตริงว่าง
การเรียงอันดับ
JSON
JSON สำหรับฟิลด์ป้ายกำกับที่แปลงเป็นอนุกรมได้มีลักษณะดังนี้
{
"fields": {
"FIELDNAME": text
}
}
โดยที่ FIELDNAME
คือสตริงที่อ้างอิงถึงช่องป้ายกำกับที่ซีเรียลไลซ์ได้ และค่าคือค่าที่จะใช้กับช่อง ค่าจะเป็นไปตามกฎเดียวกับค่าคอนสตรคเตอร์
XML
XML สำหรับฟิลด์ป้ายกำกับที่อนุกรมข้อมูลได้มีลักษณะดังนี้
<field name="FIELDNAME">text</field>
แอตทริบิวต์ name
ของโหนด field
มีสตริงที่อ้างอิงช่องป้ายกำกับที่ซีเรียลไลซ์ได้ และข้อความด้านในของโหนดคือค่าที่จะใช้กับช่อง
โปรแกรมตรวจสอบ
ช่องป้ายกำกับที่ Serializable ไม่รองรับโปรแกรมตรวจสอบ เนื่องจากผู้ใช้แก้ไขไม่ได้
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eSerializable labels function identically to regular labels but with the added capability of serializing to XML for programmatic content editing.\u003c/p\u003e\n"],["\u003cp\u003eThese labels are defined using JSON or JavaScript, specifying their type, message, arguments, and field name.\u003c/p\u003e\n"],["\u003cp\u003eSerialization of serializable labels is achieved through JSON or XML, representing the field name and its corresponding text value.\u003c/p\u003e\n"],["\u003cp\u003eUnlike regular labels, serializable labels lack validator support due to their non-editable nature.\u003c/p\u003e\n"]]],[],null,["# Serializable label fields\n\nSerializable labels work exactly the same as [normal labels](/blockly/guides/create-custom-blocks/fields/built-in-fields/label)\nexcept they also serialize to XML. They should only be used if you are editing\nthe content of a label programmatically, and wish it to serialize to XML.\n\n#### Serializable label field\n\n#### Serializable label field on a collapsed block\n\nCreation\n--------\n\n### JSON\n\n {\n \"type\": \"example_serializable_label\",\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label_serializable\",\n \"name\": \"FIELDNAME\",\n \"text\": \"a serializable label\"\n }\n ]\n }\n\n### JavaScript\n\n Blockly.Blocks['example_serializable_label'] = {\n init: function() {\n this.appendDummyInput()\n .appendField(new Blockly.FieldLabelSerializable(\"a serializable label\"), \"FIELDNAME\");\n }\n };\n\nThe serializable label field takes in an optional value, and an optional css\nclass string. Both default to an empty string.\n\nSerialization\n-------------\n\n### JSON\n\nThe JSON for a serializable label field looks like so: \n\n {\n \"fields\": {\n \"FIELDNAME\": text\n }\n }\n\nWhere `FIELDNAME` is a string referencing a serializable label field, and\nthe value is the value to apply to the field. The value\nfollows the same rules as the constructor value.\n\n### XML\n\nThe XML for a serializable label field looks like so: \n\n \u003cfield name=\"FIELDNAME\"\u003etext\u003c/field\u003e\n\nThe `field` node's `name` attribute contains a string referencing a serializable\nlabel field, and the node's inner text is the value to apply to the field.\n\nValidators\n----------\n\nSerializable label fields do not support validators, because they are not\neditable by a user."]]