new Vue ({
el: "#app",
data: {
items: ["one", "two", "three", "four", "five"]
},
methods: {
randomColor: function () {
return `hsl(${Math.floor(Math.random() * 360)}, 75%, 85%)`;
}
}
})
<div id="app">
<div
class="item-style"
v-for= "(item, index) in items"
v-bind:style="{backgroundColor: randomColor()}"
v-on:click="items.splice(index,1)">
{{ item }}
</div>
</div>
.item-style {
margin-bottom:10px;
}