Last active
February 24, 2018 07:42
-
-
Save webloglife/eceb64a2d01335e393966b1b529c13d5 to your computer and use it in GitHub Desktop.
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"> | |
<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