blockly > VariableMap > getVariable
VariableMap.getVariable() 方法
按给定名称和类型查找变量并返回它。如果未找到,则返回 null。
Signature:
getVariable(name: string, opt_type?: string): IVariableModel<IVariableState> | null;
参数
| 参数 | 类型 | 说明 |
|---|---|---|
| name | 字符串 | 要检查的名称。 |
| opt_type | 字符串 | (可选)变量的类型。如果未提供,则默认为空字符串,这是一种特定类型。 |
返回:
IVariableModel<IVariableState> | null
具有给定名称的变量,如果未找到,则为 null。