从具有视频原因的 Livewire 组件内的 js 发出事件“无法在“节点”错误上执行“replaceChild”

问题描述

我有一个组件具有使用 videojs 库加载的视频。在此组件中,我在 3 秒后发出事件以使用此 javascript 代码将此视频标记为已观看

 var player = videojs('yt-video')
        player.on('timeupdate',function() {        
            if(this.currentTime() > 3 ) {
                Livewire.emit('VideoViewed')
                this.off('timeupdate')
            }
        })

然后我在课堂上听这个事件,并进行数据库更新..

除了一个问题外,这很好用。

组件触发事件后,视频继续播放,但即使视频正在播放也会显示播放按钮,并通过控制台中的此错误删除所有视频控件。

Uncaught DOMException: Failed to execute 'replaceChild' on 'Node': The node to be replaced is not a child of this node.
    at t.<anonymous> (https://vjs.zencdn.net/7.10.2/video.min.js:19:51700)
    at t.<anonymous> (https://vjs.zencdn.net/7.10.2/video.min.js:12:25973)
    at https://vjs.zencdn.net/7.10.2/video.min.js:12:25749

enter image description here

解决方法

在视频的父 div 中使用 wire:ignore 指令解决