16进制色取透明度

  • Post author:
  • Post category:其他


export const toRgbaColor = (hexColor, opacity) => {
  const number = `0x${hexColor.substring(1)}`;
  const red = number >> 16 & 0xff;
  const green = number >> 8 & 0xff;
  const blue = number & 0xff;
  return `rgba(${red}, ${green}, ${blue}, ${opacity})`;
};



版权声明:本文为x_duoduoluo原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。