实现6位颜色值转为rgba
// 颜色格式 hex 转 rgba hexToRgba(bgColor) { let color = bgColor.slice(1); // 去掉‘#‘号 let rgba = [ parseInt(‘0x‘+color.slice(0, 2)), parseInt(‘0x‘+color.slice(2, 4)), parseInt(‘0x‘+color.slice(4, 6)), 0.15 ]; return ‘rgba(‘ + rgba.toString() + ‘)‘; }
原文:https://www.cnblogs.com/qdlhj/p/14778046.html