什么元素是可插入的?

问题描述 投票:1回答:1

我可以使用tr(表格行)作为命名插槽吗?当我使用tr作为树懒的后备内容时会发生什么?

像这样:

<x-table>
    <tr slot="x-row">
        <td>data</td>
        <td>data</td>
    </tr>
</x-table>

codepen https://codepen.io/JJia/pen/odXrWJ中的示例代码

html shadow-dom custom-element slot native-web-component
1个回答
1
投票

<tr>元素必须具有parent among <thead>, <tbody>, <tfoot> or <table>元素。

不幸的是,这些元素不能支持Shadow DOM。请参阅elements with the attachShadow() method列表。

因此,他们的第一级孩子(即<tr>)不能与slot属性一起使用。

© www.soinside.com 2019 - 2024. All rights reserved.