core-player / vue-core-video-player

🍟 A Lightweight Video Player For Vue.js.
https://core-player.github.io/vue-core-video-player/
463 stars 79 forks source link

在弹窗中使用 #83

Open 30445 opened 3 years ago

30445 commented 3 years ago

当在element-ui的dialog组件内使用时,销毁dialog组件会导致播放器报错vue.runtime.esm.js:619 [Vue warn]: Error in beforeDestroy hook: "TypeError: function () { src_instanceMap.delete(instance.VUE_DEVTOOLS_UID) } is not a function"

found in

MichalKrakow commented 3 years ago

Error in beforeDestroy hook: "TypeError: function () { return scope_1.stop(); } is not a function found in:

how come nobody else report this... Can this be environment related?
MichalKrakow commented 3 years ago
// mixins.js
...
removeAllEvents () {
      for (let item in this._events) {
        _ee.off(item, this._events[item]) // this._events[item] on "beforeDestroy" returns array of handler functions
      }
    },

so quick fix would be to check if this._events[item] is array and if so iterate over it

removeAllEvents: function removeAllEvents() {
      for (var item in this._events) {

        if(Array.isArray(this._events[item]))
        {
          for(var ev in this._events[item])
          {
            _ee.off(item, this._events[item][ev]);
          }
        }
        else
        {
          _ee.off(item, this._events[item]);
        }
      }
    },

ugly but with 4-yo over my head cant come up with nicer thing.

30445 commented 3 years ago

我试一试吧

laoer536 commented 2 years ago

我解决了这个问题。 只需要在这个组件上面加入v-if 判断有url 的时候才渲染。 而不是用v-if来关闭他,这会导致你上面的错误。