Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

334
Visualizações
Vue and videojs: how reload video

In Vue (3) how can i reload the videojs?

I have the following code:

<template>
  <video-js controls="true" preload="auto" ref="video_player" class="video-js vjs-big-play-centered">
  </video-js>
</template>


<script>

    import videojs from 'video.js'

    export default {
       data() {
         return {
          player: null
         };
       },


       mounted() {
          const element = this.$refs.video_player;
          console.log(element);

          this.player = videojs(element, {
             fluid: true,
             responsive: true,
             playbackRates: [0.5, 1, 1.5, 2],
             sources: [
             {
               src: 'url',
               type: 'application/x-mpegURL'
             }]
           })

</script>

The first time i call the component it works.

The second time, because the url is the same (change only the param id) the component is reused. I need to force the component reload because videojs on dispose method destroy the dom.

So, how can i reuse the video player with vue js or force the component to re-render (so calling again creating and mounting)?

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Let's call your component videoComponent

<VideoComponent></VideoComponent>

You can add key attribute to your component.

Thanks to that it will be re-rendered when key is changed

<VideoComponent :key="someUniqueParamId"></VideoComponent>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda