研究调查问卷:请告诉我们您使用 Blockly 的体验
开始调查问卷
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
blockly >实用程序 >颜色 >解析
utils.colour.parse() 函数
从字符串解析颜色。.parse('red') = '#ff0000'.parse('#f00') = '#ff0000'.parse('#ff0000') = '#ff0000'.parse('0xff0000') = '#ff0000'.parse('rgb(255, 0, 0)') = '#ff0000'
Signature:
export declare function parse(str: string | number): string | null;
参数
参数 |
类型 |
说明 |
str |
字符串 |号码 |
采用某种 CSS 格式的颜色。 |
返回:
字符串 |null
包含颜色的十六进制表示形式的字符串;如果无法解析,则返回 null。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-09-11。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2024-09-11。"],[[["The `utils.colour.parse()` function converts various color formats (like 'red', '#f00', 'rgb(255, 0, 0)') into a standardized hexadecimal representation (e.g., '#ff0000')."],["If the input color format is invalid or unparsable, the function will return `null`."],["This function accepts color input as either a string or a number."],["The primary purpose of this function is to provide a consistent color format for use within Blockly."]]],[]]