研究调查问卷:请告诉我们您使用 Blockly 的体验
开始调查问卷
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
blockly >实用程序 >解析 >replaceMessageReferences
utils.parsing.replaceMessageReferences() 函数
如果消息是字符串,则替换消息中的字符串表引用。例如:"%{bky_my_msg}"和“%{BKY_MY_MSG}”都会替换为 Msg['MY_MSG'] 中的值。
Signature:
export declare function replaceMessageReferences(message: string | any): string;
参数
参数 |
类型 |
说明 |
消息 |
字符串 |任意 |
消息,可以是包含字符串表引用的字符串。 |
返回:
字符串
替换了消息引用的字符串。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eThe \u003ccode\u003ereplaceMessageReferences\u003c/code\u003e function substitutes string table references within a message string with their corresponding values from the \u003ccode\u003eMsg\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eThis function handles both "%{bky_my_msg}" and "%{BKY_MY_MSG}" formats, replacing them with the value of \u003ccode\u003eMsg['MY_MSG']\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe function accepts a message, which can be a string potentially containing references or any other data type, and returns a string with references replaced.\u003c/p\u003e\n"],["\u003cp\u003eIf the input message is not a string, it is returned unchanged.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [utils](./blockly.utils_namespace.md) \\\u003e [parsing](./blockly.utils_namespace.parsing_namespace.md) \\\u003e [replaceMessageReferences](./blockly.utils_namespace.parsing_namespace.replacemessagereferences_1_function.md)\n\nutils.parsing.replaceMessageReferences() function\n-------------------------------------------------\n\nReplaces string table references in a message, if the message is a string. For example, \"%{bky_my_msg}\" and \"%{BKY_MY_MSG}\" will both be replaced with the value in Msg\\['MY_MSG'\\].\n\n**Signature:** \n\n export declare function replaceMessageReferences(message: string | any): string;\n\nParameters\n----------\n\n| Parameter | Type | Description |\n|-----------|---------------|-----------------------------------------------------------------------|\n| message | string \\| any | Message, which may be a string that contains string table references. |\n\n**Returns:**\n\nstring\n\nString with message references replaced."]]