New to vue.js and am wondering if this is a possible outcome. I have 8 different options of a background color that I want to render based on the given class name. I can achieve this with css but was wondering if there is a dynamic way with vue to accomplish this. my ideal outcome would be just change the class name in the markup and it will then render that associated bg color.
HTML:
<div class="page-header__container" :style="{ background: color }">
<div class="container">
<div class="row">
<div class="page-header">
<h1 class="page-header__text">
Page Header Lorem ipsUm
</h1>
</div>
js:
export default {
name: 'Header',
data() {
return {
color: '#333'
};
}
};
css:
bg-one{
background-color: #673AB7
}
bg-two{
background-color: #7293A0
}
bg-three{
background-color: #45B69C
}
classand notstyle, i mean:class="color"