gpt4 book ai didi

javascript - 在 Internet Explorer 中使用 shadow dom

转载 作者:行者123 更新时间:2023-11-29 21:44:18 27 4
gpt4 key购买 nike

以下代码在 chrome 中有效,但在 Internet Explorer 中无效。有没有办法在 Internet Explorer 中使用它?

    <html>
<head></head>
<body>
<div>
<h4>My Content Heading</h4>
<p>My content text</p>
</div>

<script>
var myContent = document.querySelector('div');
var shadowroot = myContent.createShadowRoot();
shadowroot.innerHTML =
'<h2>Inserted Heading</h2> <content select="p"></content>';
</script>
</body>
</html>

最佳答案

Internet Explorer(和新的 Edge 浏览器)本身不支持影子 DOM。您可以使用 polyfill实现所需的行为。

关于javascript - 在 Internet Explorer 中使用 shadow dom,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31720737/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com