แบบสำรวจการวิจัย: บอกให้เราทราบเกี่ยวกับประสบการณ์การใช้งาน Blockly
เริ่มแบบสำรวจ
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
blockly > CodeGenerator > blockToCode
เมธอด CodeGenerator.blockToCode()
สร้างโค้ดสำหรับบล็อกที่ระบุ (และบล็อกที่แนบ) ต้องเริ่มต้นโปรแกรมสร้างก่อนเรียกใช้ฟังก์ชันนี้
ลายเซ็น:
blockToCode(block: Block | null, opt_thisOnly?: boolean): string | [string, number];
พารามิเตอร์
พารามิเตอร์ |
ประเภท |
คำอธิบาย |
บล็อก |
บล็อก | ค่าว่าง |
การบล็อกที่จะสร้างโค้ด |
opt_thisOnly |
boolean |
(ไม่บังคับ) True เพื่อสร้างโค้ดสำหรับคำสั่งนี้เท่านั้น |
การคืนสินค้า:
สตริง | [สตริง, ตัวเลข]
สำหรับบล็อกคำสั่ง โค้ดที่สร้างขึ้น สำหรับการบล็อกค่า อาร์เรย์ที่มีโค้ดที่สร้างขึ้นและค่าลำดับโอเปอเรเตอร์ การแสดงผล '' หากการบล็อกเป็นค่าว่าง
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 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-07-25 UTC"],[[["The `blockToCode` method generates code for a specified Blockly block and any attached blocks."],["It requires the code generator to be initialized before use and accepts the block and an optional flag to generate code for only the given block."],["The method returns the generated code as a string for statement blocks or an array containing the code and an operator precedence for value blocks, returning an empty string if the input block is null."]]],["The `blockToCode` method generates code for a specified block and its attachments. It requires prior initialization of the code generator. It accepts a block and an optional boolean `opt_thisOnly` to limit code generation to only the provided block. The method returns either a string representing the generated code for statement blocks or an array containing code and operator order for value blocks. If the provided block is null it will return an empty string.\n"]]