1
我對VueJS非常陌生,我試圖用它來製作播放列表應用程序。製作播放清單的第一部分是相當簡單: 如何使用VueJS突出顯示列表中的項目
var playlist = [];
var playlistCurrentlyPlaying = 0;
// TODO: Highlight currently playing song
Vue.component('playlist-item', {
template: "<li class='playlist-item'>{{ text }}</li>",
props: ['text']
});
var playlistElement = new Vue({
el: '#playlist',
data: {
playlist: playlist
}
});
// Add song to the playlist
playlist.push({filepath:"url/to/file", artist:"The Band"})
以及相應的HTML
:正在使用<ul id="playlist" >
<li v-for="song in playlist" is="playlist-item" :text="song.filepath">
</li>
</ul>
的playlistCurrentlyPlaying
變量用於其他功能來跟蹤播放列表中的什麼歌的