סקר מחקר: נשמח לשמוע על החוויה שלך עם Blockly
לפתיחת הסקר
blockly > תוספים > רישום
הפונקציה extensions.register()
רושם פונקציית תוסף חדשה. תוספים הם פונקציות שעוזרות לאתחל בלוקים, ולרוב מוסיפות התנהגות דינמית כמו גורמים מטפלים בשינויים ומוטטורים. המטרה של האפליקציות האלה היא להשתמש ב-Block.applyExtension() או ב-JSON 'extensions' .
Signature:
export declare function register(name: string, initFn: Function): void;
פרמטרים
פרמטר |
סוג |
תיאור |
שם |
מחרוזת |
השם של התוסף הזה. |
initFn |
פעולה |
הפונקציה לאתחול בלוק מורחב. |
החזרות:
ריק
חריגים
{שגיאה} אם שם התוסף ריק, התוסף כבר רשום או ש-extensionFn אינו פונקציה.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2024-09-12 (שעון UTC).
[null,null,["עדכון אחרון: 2024-09-12 (שעון UTC)."],[[["Registers a new extension function that initializes blocks and adds dynamic behavior."],["Extensions are applied using `Block.applyExtension()` or the JSON \"extensions\" array."],["The `register` function takes the extension name and an initialization function as parameters."],["Throws an error if the extension name is invalid, already exists, or the provided initialization function is not a function."]]],["The `Extensions.register()` function registers a new extension for initializing blocks. It takes two parameters: `name` (a string for the extension's name) and `initFn` (a function to initialize the block). Registered extensions add dynamic behavior like onchange handlers and mutators. This function returns void and throws an error if the extension name is empty, already registered, or if `initFn` is not a function. Extensions are applied via `Block.applyExtension()` or the JSON \"extensions\" array.\n"]]