likaia / js-screen-shot

web端自定义截图插件(原生JS版)
https://www.kaisir.cn/js-screen-shot/
MIT License
808 stars 107 forks source link

destroyComponents报错 #141

Closed hahadaba closed 10 months ago

hahadaba commented 11 months ago

Version of js-screen-shot

1.9.9-rc.7

Operating system and its version

Windows

Browser and its version

版本 120.0.2210.61 (正式版本) (64 位)

Sandbox to reproduce

No response

What happened?

// 创建实例 let instance = new ScreenShot({ completeCallback, closeCallback, cancelCallback, triggerCallback, enableWebRtc: finalEnableWebRtc, canvasWidth: window.innerWidth, canvasHeight: window.innerHeight, noScroll: false, showScreenData: true, position: { left: 0, top: 0 }, cropBoxInfo: { x: 200, y: 200, w: window.innerWidth - 400, h: window.innerHeight - 400, }, level: 3000, });

// 在回调中销毁实例 const completeCallback = () => { instance.destroyComponents() // <------报错了 instance=null }

报错信息

Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
likaia commented 11 months ago

Hello @hahadaba. Your feedback has been received, and you will be notified in the issue area when the problem is resolved. 你好 @hahadaba,已收到你反馈的问题,问题解决后将在issue区域通知你。

likaia commented 10 months ago

completeCallback

你的用法不对,当completeCallback回调执行的时候,dom已经被销毁了。你再次执行销毁方法,找不到dom,自然就报错了。