blockly > Workspace > getVariable

Workspace.getVariable() 方法

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

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

Signature:

getVariable(name: string, opt_type?: string): IVariableModel<IVariableState> | null;

参数

参数 类型 说明
name 字符串 要检查的名称。
opt_type 字符串 (可选)变量的类型。如果未提供,则默认为空字符串,这是一种特定类型。

返回

IVariableModel<IVariableState> | null

具有指定名称的变量。