したがって、 x-tag Web コンポーネント ライブラリを使用すると、次のような HTML に表示されるカスタム要素を作成できることがわかります。
<x-my-custom-element>my content</x-my-custom-element>
ただし、次のように複数のカスタム サブ要素を作成したい場合はどうすればよいでしょうか。
<x-my-custom-element>
<x-my-custom-element-child>
<x-my-custom-element-grandchild></x-my-custom-element-grandchild>
</x-my-custom-element-child>
</x-my-custom-element>
xtag.register()
次のように、単純に3 回呼び出すのが正しい方法です。
xtag.register('x-my-custom-element', {...});
xtag.register('x-my-custom-element-child', {...});
xtag.register('x-my-custom-element-grandchild', {...});
また、サブ要素を常に別の要素の子にする方法はありますか? 言い換えれば、これはうまくいくでしょう:
<x-my-custom-element-parent>
<x-my-custom-element-child></x-my-custom-element-child>
</x-my-custom-element-parent>
しかし、これはそうではありません:
<x-my-custom-element-child>
<x-my-custom-element-parent></x-my-custom-element-parent>
</x-my-custom-element-child>