Blockly 已於 2025 年 11 月 10 日移交給 Raspberry Pi Foundation!請參閱網誌文章和常見問題。
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
封鎖 >擴充功能 >registerMutator
Extensions.registerMutator() 函式
註冊新的擴充功能函式,將變動器新增至區塊。在註冊時,這會對可變器執行一些基本的例行性檢查。如果 Compose 和分解都已在混合中定義,包裝函式也可能會在區塊中加入變動器對話方塊。
Signature:
export declare function registerMutator(name: string, mixinObj: any, opt_helperFn?: () => any, opt_blockList?: string[]): void;
參數
| 參數 |
類型 |
說明 |
| 名稱 |
字串 |
此變動器擴充功能的名稱。 |
| mixinObj |
不限 |
要混合的值。 |
| opt_helperFn |
() =>任何 |
(選用) 在物件中混合之後要套用的選用函式。 |
| opt_blockList |
string[] |
(選用) 切換子對話方塊動態顯示的區塊清單。 |
傳回:
void
例外狀況
如果異動無效或無法套用至區塊,則為 {Error}。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 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 `registerMutator` function registers a new mutator extension for blocks. It takes the mutator's name, a mixin object defining its behavior, and optional parameters like a helper function and a block list for a mutator dialog's flyout. It verifies the mutator's validity and can add a dialog if 'compose' and 'decompose' are defined. This function will raise an error if the mutation is invalid. It does not return a value.\n"]]