颜色十六进制转rgba的方法

 hexToRgba(hex, opacity) {
        let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
        if(result){
        return `rgba(${parseInt(result[1], 16)},${parseInt(
          result[2],
          16
        )},${parseInt(result[3], 16)},${opacity})`;
        }
    }

你可能感兴趣的:(颜色十六进制转rgba的方法)