研究调查问卷:请告诉我们您使用 Blockly 的体验
开始调查问卷
blockly >屏蔽 >getIcon
Block.getIcon() 方法
Signature:
getIcon<T extends IIcon>(type: IconType<T> | string): T | undefined;
参数
参数 |
类型 |
说明 |
类型 |
IconType<T>|字符串 |
要检索的图标的类型。在使用 typescript 时,最好传递 IconType 以进行正确的类型检查。 |
返回:
T |未定义
如果块上存在具有指定类型的图标,则返回该图标,否则将处于未定义状态。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-08-21。
[null,null,["最后更新时间 (UTC):2024-08-21。"],[[["The `Block.getIcon()` method retrieves a specific icon associated with a block, if available."],["It accepts an `IconType` or a string representing the icon type as input."],["The method returns the requested icon if found, otherwise it returns `undefined`."]]],["The `Block.getIcon()` method retrieves an icon associated with a block. It accepts a parameter `type`, which specifies the icon type, preferably as an `IconType` for TypeScript type checking, or as a string. The method returns the icon of the specified type if it exists on the block, otherwise, it returns undefined. This allows users to access a specific icon from a Block by providing its corresponding type.\n"]]