Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
blockly > CodeGenerator > blockToCode
Metoda CodeGenerator.blockToCode()
Wygeneruj kod dla określonego bloku (i dołączonych bloków). Przed wywołaniem tej funkcji należy zainicjować generator.
Podpis:
blockToCode(block: Block | null, opt_thisOnly?: boolean): string | [string, number];
Parametry
Parametr |
Typ |
Opis |
blok |
Zablokuj | wartość null |
Blok, dla którego zostanie wygenerowany kod. |
opt_thisOnly |
wartość logiczna |
(Opcjonalnie) Prawda, aby wygenerować kod tylko dla tej instrukcji. |
Zwroty:
ciąg znaków | [ciąg, liczba]
W przypadku bloków instrukcji jest to wygenerowany kod. W przypadku bloków wartości jest to tablica zawierająca wygenerowany kod i wartość kolejności operatorów. Zwraca „” jeśli blok ma wartość null.
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2024-08-21 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 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"]]