blockly > CodeGenerator > blockToCode
CodeGenerator.blockToCode() yöntemi
Belirtilen blok (ve ekli bloklar) için kod oluşturur. Bu işlev çağrılmadan önce oluşturucunun başlatılması gerekir.
İmza:
blockToCode(block: Block | null, opt_thisOnly?: boolean): string | [string, number];
Parametreler
Parametre |
Tür |
Açıklama |
engelle |
Engelle | boş |
Kodun oluşturulacağı blok. |
opt_thisOnly |
boolean |
(İsteğe bağlı) Yalnızca bu ifadeye yönelik kod oluşturmak için True (doğru) değerini kullanın. |
Şunu döndürür:
dize | [dize, sayı]
İfade blokları için, oluşturulan kod. Değer blokları için, oluşturulan kodu ve operatör sıra değerini içeren bir dizi. "" değerini döndürür (engelleme null ise).
Aksi belirtilmediği sürece bu sayfanın içeriği Creative Commons Atıf 4.0 Lisansı altında ve kod örnekleri Apache 2.0 Lisansı altında lisanslanmıştır. Ayrıntılı bilgi için Google Developers Site Politikaları'na göz atın. Java, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2024-08-21 UTC.
[null,null,["Son güncelleme tarihi: 2024-08-21 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"]]