Created
March 17, 2020 10:44
-
-
Save sioniks/3b77ca08c0a70f420c0e14d2f1e1d3f2 to your computer and use it in GitHub Desktop.
convert HEX to rgba Vue.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data: { | |
return { | |
opacity: 50 | |
} | |
}, | |
methods: { | |
convertHex: function (color) { | |
color = color.replace('#', '') | |
let r = parseInt(color.substring(0, 2), 16) | |
let g = parseInt(color.substring(2, 4), 16) | |
let b = parseInt(color.substring(4, 6), 16) | |
let result = 'rgba(' + r + ',' + g + ',' + b + ',' + this.opacity / 100 + ')' | |
return result | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment