Skip to content

color 颜色格式判断

isColor 判断是否是颜色表达式

source

ts
import {isColor} from 'fe-toolsbox'
isColor('#AAA')
isColor('#AAACCC')
isColor('rgb(0,0,0)')
isColor('rgba(0,0,0,0.1)')
true
true
true
true

isHexColor 判断 hex 颜色表达式

source

ts
import {isHexColor} from 'fe-toolsbox'
isHexColor('#AAA')
isHexColor('rgb(0,0,0)')
isHexColor('rgba(0,0,0,0.1)')
true
false
false

isRgbColor 判断 RGB 颜色表达式

source

ts
import {isRgbColor} from 'fe-toolsbox'
isRgbColor('#AAA')
isRgbColor('rgb(0,0,0)')
isRgbColor('rgba(0,0,0,0.1)')
false
true
false

isRgbaColor 判断 RGBA 颜色表达式

source

ts
import {isRgbaColor} from 'fe-toolsbox'
isRgbaColor('#AAA')
isRgbaColor('rgb(0,0,0)')
isRgbaColor('rgba(0,0,0,0.1)')
false
false
true

fe-toolsbox 前端业务常用工具库