blockly > Workspace > getVariableById

Workspace.getVariableById() 方法

v12:使用 Blockly.Workspace.getVariableMap().getVariableById。

按给定 ID 查找变量并返回它。如果未找到,则返回 null。

Signature:

getVariableById(id: string): IVariableModel<IVariableState> | null;

参数

参数 类型 说明
id 字符串 要检查的 ID。

返回

IVariableModel<IVariableState> | null

具有指定 ID 的变量。