blockly > 工作區 > getVariable

Workspace.getVariable() 方法

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

根據指定名稱尋找變數並傳回。如果找不到,則傳回空值。

Signature:

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

參數

參數 類型 說明
名稱 字串 要檢查的名稱。
opt_type 字串 (選用) 變數類型。如未提供,則預設為空字串,這是一種特定類型。

退貨:

IVariableModel<IVariableState> | null

具有指定名稱的變數。