I found this question and recently I was implementing some UIs using Vue.js so this can be a good alternative.
First your code is not hiding target
when you click on View Profile. You are overriding the content target
with div2
.
let multiple = new Vue({_x000D_
el: "#multiple",_x000D_
data: {_x000D_
items: [{_x000D_
id: 0,_x000D_
name: 'View Profile',_x000D_
desc: 'Show profile',_x000D_
show: false,_x000D_
},_x000D_
{_x000D_
id: 1,_x000D_
name: 'View Results',_x000D_
desc: 'Show results',_x000D_
show: false,_x000D_
},_x000D_
],_x000D_
selected: '',_x000D_
shown: false,_x000D_
},_x000D_
methods: {_x000D_
showItem: function(item) {_x000D_
if (this.selected && this.selected.id === item.id) {_x000D_
item.show = item.show && this.shown ? false : !item.show;_x000D_
} else {_x000D_
item.show = (this.selected.show || !item.show) && this.shown ? true : !this.shown;_x000D_
}_x000D_
this.shown = item.show;_x000D_
this.selected = item;_x000D_
},_x000D_
},_x000D_
});
_x000D_
<div id="multiple">_x000D_
<button type="button" v-for="item in items" v-on:click="showItem(item)">{{item.name}}</button>_x000D_
_x000D_
<div class="" v-if="shown">: {{selected.desc}}</div>_x000D_
</div>_x000D_
_x000D_
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.7/vue.js"></script>
_x000D_