function rgb2hex(sRGB) { // 填写JavaScript if(!sRGB.includes('rgb')){ return sRGB } let str=sRGB.slice(4,sRGB.length-1) let arr=str.split(',') let result='#' for(let i=0;i<arr.length;i++){ let res = parseInt(arr[i]).toString(16); //if (res.length <2) { // res=res.padStart(2, "0"); //} result = result +( res.length<2?'0'+res:res); } return result }