Skip to content

Instantly share code, notes, and snippets.

@webloglife
Last active February 24, 2018 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webloglife/eceb64a2d01335e393966b1b529c13d5 to your computer and use it in GitHub Desktop.
Save webloglife/eceb64a2d01335e393966b1b529c13d5 to your computer and use it in GitHub Desktop.
<div id="app">
<input type="text" v-model="search_query" placeholder="文字を入力してください">
<ul>
<li v-for="album in filterAlbum">
{{ album }}
</li>
</ul>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script>
new Vue({
el: '#app',
data: {
search_query: '',
album:[
"Kill 'em All",
"Ride the Lightning",
"Master of Puppets",
"...And Justice for All",
"Metallica",
"Load",
"Reload",
"St. Anger",
"Death Magnetic",
"Hardwired... to Self-Destruct",
]
},
computed:{
filterAlbum: function(){
query = this.search_query;
return this.album.filter ( function ( album ) {
return album.indexOf(query) !== -1
})
}
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment