blockly > WorkspaceSvg > createVariable
WorkspaceSvg.createVariable() 方法
创建一个具有指定名称的新变量。更新浮出控件以立即显示新变量。
Signature:
createVariable(name: string, opt_type?: string | null, opt_id?: string | null): VariableModel;
参数
参数 | 类型 | 说明 |
---|---|---|
name | string | 新变量的名称。 |
opt_type | 字符串 | null | (可选)变量的类型,例如“int”或“string”。无需具有唯一性。Field_variable 可以根据变量类型过滤变量。这将默认为 '',这是一个特定类型。 |
opt_id | 字符串 | null | (可选)变量的唯一 ID。该值默认为 UUID。 |
返回:
新创建的变量。