colorTransform(sHex, alpha = 1) {let reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$//* 16进制颜色转为RGB格式 */let sColor = sHex.toLowerCase()if (sColor && reg.test(sColor)) {if (sColor.length === 4) {let sColorNew = '#'for (let i = 1; i < 4; i += 1) {sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1))}sColor = sColorNew}// 处理六位的颜色值let sColorChange = []for (let i = 1; i < 7; i += 2) {// eslint-disable-next-line radixsColorChange.push(parseInt(`0x${sColor.slice(i, i + 2)}`))}return `rgba(${sColorChange.join(',')},${alpha})`}return sColor}
1200字范文,内容丰富有趣,写作的好帮手!