Last active
February 25, 2018 16:13
-
-
Save webloglife/abb2f09e2dff2b00399ba8c67d4bef7b 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
<ul id="app"> | |
<li v-for="(item,index) in items"> | |
<img v-bind:src="item.snippet.thumbnails.high.url"> | |
<span class="title">{{ item.snippet.title }}</span> | |
</li> | |
</ul> | |
<script src="https://cdn.jsdelivr.net/npm/vue"></script> | |
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> | |
<script> | |
axios.get('https://www.googleapis.com/youtube/v3/playlistItems',{ | |
params: { | |
part: 'snippet', | |
playlistId: 'PL55713C70BA91BD6E',/*プレイリストのID*/ | |
maxResults: 6, /*表示する件数*/ | |
key: 'APIキー' /*Youtube Data API で使う認証キー*/ | |
} | |
}).then((response) => { | |
Init(response.data.items); | |
}).catch( error => { console.log(error); }); | |
function Init(data){ | |
new Vue({ | |
el: '#app', | |
data: { | |
items:[] | |
}, | |
created: function(){ | |
for(var i = 0; i < data.length; i++){ | |
this.items.push(data[i]); | |
} | |
}, | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment