vue-dplayerビデオプレーヤーの実例コード


公式サイト
vue-dplayer
dplayer-doc

デフォルトのoptionsにビデオリンクがない場合は、そのままthis.options.video.url=videoPathを通じてビデオリンクを設定することは無効です。
まずプレイヤーのインスタンスthis.$refs.player.dpを取得して、スウィッチビデオ()を通じてurlを修正する必要があります。

<template>
 <d-player ref="player" :options="options"></d-player>
</template>

<script type="text/ecmascript-6">
 import dPlayer from 'vue-dplayer'
 import 'vue-dplayer/dist/vue-dplayer.css'

 export default {
 name: 'in-video',
 props: {
  source: {
  type: String,
  default: ''
  }
 },
 data () {
  return {
  player: null,
  options: {
   video: {
   url: ''
   },
   contextmenu: [
   {}
   ]
  }
  }
 },
 mounted() {
  this.player = this.$refs.player.dp
 },
 created() {
  this._setVideoUrl(this.source)
 },
 methods: {
  //         
  _setVideoUrl (url) {
  this.player.switchVideo({
   url: url
  })
  }
 },
 components: {
  dPlayer
 }
 }
</script>