Answer the question
In order to leave comments, you need to log in
How to make a color mixer in vue.js?
Hello. How to make a mixer to change colors. I made this example ( https://zaladdin.github.io/praktika.github.io/ ). But I need to have 3 fields for entering values, each of them which will correspond to the values of R, G, B . That is, change the background color using the background'a rgb parameter, and not just background.
Answer the question
In order to leave comments, you need to log in
Let's create an object that will contain the color components:
colorComponents: {
r: 0,
g: 0,
b: 0,
},
<div v-for="(v, k) in colorComponents">
{{ k }}
<input v-model="colorComponents[k]" type="range" min="0" max="255">
{{ v }}
</div>
computed: {
style() {
return {
'background-color': `rgb(${Object.values(this.colorComponents).join(',')})`,
};
},
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question