با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
blockly > CodeGenerator > blockToCode
متد CodeGenerator.blockToCode().
کد برای بلوک مشخص شده (و بلوک های پیوست شده) ایجاد کنید. قبل از فراخوانی این تابع، مولد باید مقداردهی اولیه شود.
امضا:
blockToCode(block: Block | null, opt_thisOnly?: boolean): string | [string, number];
پارامترها
پارامتر | تایپ کنید | توضیحات |
---|
مسدود کردن | بلوک | تهی | بلوکی برای تولید کد. |
opt_thisOnly | بولی | (اختیاری) درست برای تولید کد فقط برای این عبارت. |
برمی گرداند:
رشته | [رشته، شماره]
برای بلوک های بیانیه، کد تولید شده. برای بلوک های مقدار، یک آرایه حاوی کد تولید شده و یک مقدار سفارش اپراتور. اگر بلوک تهی باشد، '' را برمیگرداند.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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 بهوقت ساعت هماهنگ جهانی."],[[["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"]]