Skip to content

Home > robinson > isRgb

isRgb() function

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

判断是否为rgb颜色

Signature:

typescript
declare function isRgb(color: string): boolean;
declare function isRgb(color: string): boolean;

Parameters

ParameterTypeDescription
colorstring需要验证的颜色字符串

Returns:

boolean

{boolean} 如果是rgb颜色返回true,否则返回false

Example

JavaScript
    isRgb('#FD7086') //false
    isRgb('rgba(253,112,134,0.9)') //false
    isRgb(null) // false
    isRgb({}) // false
    isRgb('rgb(255,255,255)') // true
    isRgb('rgb(256,256,256)') //false
    isRgb('#FD7086') //false
    isRgb('rgba(253,112,134,0.9)') //false
    isRgb(null) // false
    isRgb({}) // false
    isRgb('rgb(255,255,255)') // true
    isRgb('rgb(256,256,256)') //false

Released under the MIT License.