Vue
HTML
<div id="app">
<div>
<button @click="click">{{a.text}}</button>
<span :style="{color: a.color}">{{a.color}}</span>
{{a.image}}
</div>
<div :color="b.color">
<button>{{b.text}}</button>
<span :style="{color: b.color}">{{b.color}}</span>
{{b.image}}
</div>
</div>
Vue
new Vue({
el: "#app",
data: {
a: {
text: "A",
color: "red",
image: "ringo.jpg"
},
b: {
text: "B",
color: "red",
image: "banana.jpg"
}
},
methods: {
click () {
this.a.color = "blue"
this.a.image = "banana.jpg"
this.b.text = "C"
this.b.image = "melon.jpg"
}
}
})