封鎖 >CodeGenerator >blockToCode
CodeGenerator.blockToCode() 方法
為指定區塊 (及附加的區塊) 產生程式碼。產生器必須先初始化,才能呼叫這個函式。
Signature:
blockToCode(block: Block | null, opt_thisOnly?: boolean): string | [string, number];
參數
參數 |
類型 |
說明 |
封鎖 |
封鎖 |空值 |
要產生程式碼的區塊。 |
opt_thisOnly |
布林值 |
(選用) 如果只產生這個陳述式的程式碼,則為 True。 |
傳回:
字串 |[字串,數字]
如果是陳述式區塊,則產生的程式碼。針對值區塊,此為陣列,內含產生的程式碼和運算子順序值。傳回「」如果區塊為空值
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-08-21 (世界標準時間)。
[null,null,["上次更新時間:2024-08-21 (世界標準時間)。"],[[["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."]]],[]]