video.js多个视频初次加载报错The element or ID supplied is not valid

多个视频总是报这个错误,后来多次尝试加了定时器才可以了

     let id =  "my-video" + i.toString();
      let that = this;
        setTimeout(function() {
     
         that.plays.push(  videojs(id));
            let myPlayer = videojs(id);
              videojs(id).ready(function() {
     
                     let myPlayer = this;
                     myPlayer.play();
                  });
        }, 5000);

同时因为目录的切换,需要关闭视频流或者页面切换时候,放在destory里面可以实现关闭

   this.plays.filter(temp => temp.dispose());

你可能感兴趣的:(vue,video.js)