Skip to content

Instantly share code, notes, and snippets.

@simoebenhida
Last active September 14, 2018 19:23
Show Gist options
  • Save simoebenhida/cf36ef6eb0474efca3121d800fff8bef to your computer and use it in GitHub Desktop.
Save simoebenhida/cf36ef6eb0474efca3121d800fff8bef to your computer and use it in GitHub Desktop.
Faicel Vue Example
<div id="app">
<v-app id="inspire">
{{ likes }}
<div class="text-xs-center">
<div>
<v-btn v-for="(like, index) in likes" :key="index" flat icon color="blue lighten-2">
<v-icon v-if="!itIsLiked(like)" @click="likeThis(like)">thumb_up</v-icon>
<span v-else @click="likeThis(like)">ok</span>
</v-btn>
</div>
</div>
</v-app>
</div>
new Vue({
el: '#app',
data() {
return {
isLiked : [],
likes : [
{name: 'one'},
{name: 'two'},
{name: 'tree'},
{name: 'four'},
{name: 'five'},
],
}
},
methods:{
likeThis(like){
if(this.itIsLiked(like))
{
this.isLiked = this.isLiked.filter((item) => {
console.log(item)
return item != like
})
}else {
this.isLiked.push(like)
}
// this.likes[index].liked = true
},
itIsLiked(like) {
return this.isLiked.includes(like);
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment