“目标元素不是根的后代”的含义是什么? [英] What is the meaning of "target element is not a descendant of root"?

查看:231
本文介绍了“目标元素不是根的后代”的含义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Chrome的控制台中收到以下警告:
IntersectionObserver.observe(target):target元素不是root的后代。

I got the following warning in the Chrome's console: "IntersectionObserver.observe(target): target element is not a descendant of root."

这是什么意思?我怎么才能找到它的原因,以解决它?

What is the meaning of this? How could I find the reason for it, in order to fix it?

推荐答案

当我创建一个HTMLVideoElement在JS中,但不会将它添加到文档的主体中,然后再播放它以提取第一帧图像。

I got this warning when I was creating a HTMLVideoElement in JS, but not adding it to the body of the document, before playing it to extract the first frame image.

我通过将其显示设置为无,将节点附加为主体的子节点,并在稍后的承诺中将元素从主体中移除。

I worked around it by setting its display to none, appending the node as a child of the body, and in a later promise removing the element from the body.

所以,我会检查您是否创建了任何DOM JS中的元素,而不是将它们添加到HTML文档的主体中。

So, I'd check if you're creating any DOM elements in JS, and not adding them to the body of the HTML document.

这篇关于“目标元素不是根的后代”的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆