vertically-challenged
@vertically-challenged

Есть JS файл, как его исполнить внутри VUE?

Есть JS файл такого содержания:
require('./plugin/components/ads-label_5');
require('./plugin/components/black-poster_5');
require('../styles/videojs.vast.vpaid.scss');

const videoJsVAST = require('./plugin/videojs.vast.vpaid');

videojs.plugin('vastClient', videoJsVAST);


Как его исполнить внутри этого компонента?
<template>
  <div>
    <video 
      ref="videoPlayer" 
      class="video-js"
      controls 
      preload="auto"
      poster="http://vjs.zencdn.net/v/oceans.png"
      :data-setup='JSON.stringify({
        plugins: {
          vastClient: {
            adTagXML: banner,
            adsEnabled: true
          }
        }
      })'
    >
      <source src="http://vjs.zencdn.net/v/oceans.mp4" type='video/mp4'/>
    </video>
  </div>
</template>

<script lang="ts">
import videojs from 'video.js'

export default {
  name: 'VideoPlayer',
  props: {
    banner: String,
    options: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      player: null as any
    }
  },
  mounted() {
    this.player = videojs(this.$refs.videoPlayer, {
      autoplay: true,
      controls: true,
      ...this.options
    }, () => {
      this.player.log('onPlayerReady', this.player)
    })
  },
  beforeUnmount() {
    if (this.player) {
      (this.player as any).dispose()
    }
  }
}
</script>

<style>
.video-js {
  width: 350px;
  height: 260px;
}
</style>
  • Вопрос задан
  • 109 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы