Vue-Dplayer视频播放器实例代码,如何编写长尾词?

2026-04-05 20:212阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计242个文字,预计阅读时间需要1分钟。

Vue-Dplayer视频播放器实例代码,如何编写长尾词?

官网上vue-dplayer的示例代码中,如果默认options中没有视频链接,之后设置视频链接时,直接使用this.options.video.url=videoPath是无效的。需要先获取播放器的实例,即this.$refs.player.dp,然后通过实例的url属性来设置视频链接。

官网

vue-dplayer

dplayer-doc

示例

如果默认 options 中没有视频链接,之后设置视频链接时,直接通过 this.options.video.url = videoPath 是无效的

需要先获取到播放器的实例 this.$refs.player.dp ,然后通过 switchVideo() 对 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>


Vue-Dplayer视频播放器实例代码,如何编写长尾词?

本文共计242个文字,预计阅读时间需要1分钟。

Vue-Dplayer视频播放器实例代码,如何编写长尾词?

官网上vue-dplayer的示例代码中,如果默认options中没有视频链接,之后设置视频链接时,直接使用this.options.video.url=videoPath是无效的。需要先获取播放器的实例,即this.$refs.player.dp,然后通过实例的url属性来设置视频链接。

官网

vue-dplayer

dplayer-doc

示例

如果默认 options 中没有视频链接,之后设置视频链接时,直接通过 this.options.video.url = videoPath 是无效的

需要先获取到播放器的实例 this.$refs.player.dp ,然后通过 switchVideo() 对 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>


Vue-Dplayer视频播放器实例代码,如何编写长尾词?