一、 下载ckplayer插件
官网地址:http://www.ckplayer.com/down/
二、加压后将ckplayer放进VUE项目的static目录下:
三、在index.html中引入ckplayer.js文件
<script src="./static/ckplayer/ckplayer.js"></script>
四、创建VUE组件
<template>
<div id="video"></div>
</template>
<script>
export default {
name: 'ckplayer',
props: ['videoUrls','autoPlay','poster','loop'],
data () {
return {
player: ''
}
},
watch: {
videoUrls: {
handler(newVideoUrls, VideoUrls) {
this.initVideo(newVideoUrls,this.autoPlay);
},
immediate: true
}
},
mounted: function(){
this.initVideo(this.videoUrls,this.autoPlay);
},
methods:{
initVideo(videoUrls,autoPlay) {
// 挂载完成后进行
var videoObject = {
container: '#video',