Last active
September 14, 2018 19:23
-
-
Save simoebenhida/cf36ef6eb0474efca3121d800fff8bef to your computer and use it in GitHub Desktop.
Faicel Vue Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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