Blockly 于 2025 年 11 月 10 日移至 Raspberry Pi Foundation!请阅读博文和常见问题解答。
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
blockly >扩展程序 >registerMutator
Extensions.registerMutator() 函数
注册一个新的扩展函数,该函数用于向块添加赋值函数。在注册时,此操作会对变更器执行一些基本的完整性检查。如果对 mixin 同时定义了 Compose 和 Decompose,封装容器还可以向该块添加一个变更器对话框。
Signature:
export declare function registerMutator(name: string, mixinObj: any, opt_helperFn?: () => any, opt_blockList?: string[]): void;
参数
| 参数 |
类型 |
说明 |
| name |
字符串 |
此更改器扩展程序的名称。 |
| mixinObj |
任意 |
要混入的值。 |
| opt_helperFn |
() =>任意 |
(可选)混合对象后要应用的可选函数。 |
| opt_blockList |
字符串[] |
(可选)要在更改器对话框的浮出控件中显示的块的列表。 |
返回:
void
异常
{Error}(如果变更无效或无法应用于块)。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):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"]]