1👍
✅
https://jsfiddle.net/kyz19b7r/
new Vue({
el: "#app",
data: {
bgColour: 'blue',
classes: [ 'blue', 'red', 'green'
]
}
})
body {
background: #fff;
padding: 20px;
font-family: Helvetica;
}
#app {
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
.blue {
background: blue;
}
.red {
background: red;
}
.green {
background: green;
}
<div id="app" :class="bgColour">
<select v-model="bgColour">
<option v-for="myClass in classes" :value="myClass">{{ myClass }}</option>
</select>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
👤Nate
Source:stackexchange.com