VideoEmbed.vue 483 B

123456789101112131415161718192021
  1. <template>
  2. <div>
  3. <iframe class="w-full aspect-video" :src="embedUrl" frameborder="0" allowfullscreen></iframe>
  4. </div>
  5. </template>
  6. <script setup>
  7. const props = defineProps({
  8. src: {
  9. type: String,
  10. required: true
  11. }
  12. })
  13. const embedUrl = computed(() => {
  14. const url = new URL(props.src);
  15. const params = new URLSearchParams(url.search);
  16. const videoId = params.get('v');
  17. return `https://www.youtube.com/embed/${videoId}`;
  18. });
  19. </script>