function rgb2hex(sRGB) { // 填写JavaScript const reg = /\d+/g const arr = sRGB.match(reg) return arr? arr.reduce((pre,cur)=> { let hex = (cur*1).toString(16) hex = hex.length > 1 ? hex : '0'+ hex return pre + hex },'#') : sRGB }