blockly > registry > getObject

registry.getObject() 函数

获取具有指定名称和类型的对象。

Signature:

export declare function getObject<T>(type: string | Type<T>, name: string, opt_throwIfMissing?: boolean): T | null;

参数

参数 类型 说明
类型 字符串 | 类型<T> 插件的类型。(例如类别)
name string 插件的名称。(例如 logo_category)
opt_throwIfMissing boolean (可选)如果我们找不到对象,是否要抛出错误。

返回

T | null

具有指定名称和类型的对象,如果不存在,则为 null。