JS色值#f97db3转换为16进制int

_hexToRgb (hex) {
        const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
        return result ? {
            r: parseInt(result[1], 16),
            g: parseInt(result[2], 16),
            b: parseInt(result[3], 16)
        } : null;
    }

 

posted @ 2020-06-24 11:32  野生野鸡码农  阅读(283)  评论(0编辑  收藏  举报