Just starting out with vue.js and exploring the possibilities. I have a scenario where I need to dynamically change the background color based on a class name in vue. Is there a way to achieve this without relying solely on CSS? Ideally, I would like to simply update the class name in the HTML markup and have the associated background color render automatically.
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
}