研究调查问卷:请告诉我们您使用 Blockly 的体验
开始调查问卷
blockly >代码生成器 >CodeGeneratorgetVariableName
CodeGenerator.getVariableName() 方法
获取用户定义的变量的唯一合法名称。在调用此方法之前,必须已初始化类的 nameDB_
属性。这通常在代码生成器类的 init
函数中完成。
Signature:
getVariableName(nameOrId: string): string;
参数
参数 |
类型 |
说明 |
nameOrId |
字符串 |
要获取其名称的变量的 ID,或与 ID 不相关的变量的建议名称。 |
返回:
字符串
变量的唯一合法名称。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-08-21。
[null,null,["最后更新时间 (UTC):2024-08-21。"],[[["The `getVariableName` method generates a unique, legal name for a user-defined variable within Blockly's code generation process."],["Before using this method, the `nameDB_` property must be initialized, usually done within the code generator's `init` function."],["It accepts either the variable's ID or a proposed name as input and returns a suitable, unique name."]]],[]]