将ckplayer官网的压缩包解压放到public文件夹下,在index.httml中引入
然后就可以在组件中引用了
ckPlayerInit = () => { console.log(window.ckplayer); let videoObject = { container: '#video', //容器的ID或className variable: 'player', //播放函数名称 loop: false, //播放结束是否循环播放 autoplay: true,//是否自动播放 // poster: 'material/poster.jpg', //封面图片 /* preview: { //预览图片 file: ['material/mydream_en1800_1010_01.png', 'material/mydream_en1800_1010_02.png'], scale: 2 },*/ video: [ ['https://ckplayer-video.oss-cn-shanghai.aliyuncs.com/sample-mp4/d0897b4e9ddd9a5.mp4', 'video/mp4', '中文标清', 0], ] } // setTimeout(() => { let player = new window.ckplayer(videoObject) // }, 1000); }; 在dom中定义容器( <div id="video" className={styles.content_video_momitor}></div> )