Home > front end >  Prompt error: Uncaught TypeError: shadowHost createShadowRoot is not a function
Prompt error: Uncaught TypeError: shadowHost createShadowRoot is not a function

Time:11-04

Tip said createShadowRoot is not a function, running as shown in the figure below:

 

<meta HTTP - equiv="content-type" Content="text/HTML. Charset=gb2312 "/& gt;
Overflow
<style>
# app {margin: 100 px; }
The shadow - child {
color: red;
}
</style>

<body>


Alert (SDF)
//1. Get shadow shadow host host
Var shadowHost=document. QuerySelector (' shadow - CLS ');

//2. Create a shadow shadow root
Var shadowRoot=shadowHost. CreateShadowRoot ();

//3. Shadow root as shadow first node of the tree, the other nodes, such as the following p nodes are its child nodes,
ShadowRoot. InnerHTML='& lt; P & gt; I am a child node & lt;/p> ';
</script>



I do not know what reason?

CodePudding user response:

Create dom use createElement method (' xx ') div/p/span/a/ul/li...
  • Related