[Vuejs]-How to get src from v-for looped element

0👍

Not sure why you are doing it this way, how about

<li v-for="file in lesson.files">
  <a @click="sourceReplace(file.src)" class="copied" :id="file.file_id">
     {{file.name}}  
  </a>
</li>

and then

methods: {
  sourceReplace(src){
    var currentVideo = document.getElementById('current-video');
    var currentSource = document.getElementById('current-source');
    var link = src;
    currentSource.setAttribute('src', link);
    currentVideo.setAttribute('src', link);
    alert(link)
    currentVideo.load();
    currentVideo.play();
  }
},

Leave a comment