hexToRgba(hexColor,opcity) {
const hex = hexColor.replace('#', '')
const r = parseInt(hex.substring(0, 2), 16)
const g = parseInt(hex.substring(2, 4), 16)
const b = parseInt(hex.substring(4, 6), 16)
return `rgba(${r}, ${g}, ${b}, ${opacity})`
}
// 调用
hexToRgba('#ffffff','0.5')
十六进制颜色转为rgba函数
最新推荐文章于 2024-05-30 16:35:50 发布