ecmascript-6 - 作为开槽节点
问题描述
我已经定义了一个影子模板如下:
<table id="overviewbox-loadingbox">
<thead>
<tr>
<slot name="table-header"></slot>
</tr>
</thead>
<tbody>
<div id="loadingbox"></div>
</tbody>
</table>
用户应该通过以下方式提供自己的<th>
s:
<th slot="table-header" data-column_name="description">describing here</th>
但是,这不起作用。一旦我更改<th>
为<span>
,所有其他内容都未更改,插槽节点就会显示出来。这是因为有一些关于使用<th>
和<slot>
在一起的无证怪癖吗?谢谢。
解决方案
<tr>
并且<tbody>
允许的孩子数量非常有限。因此,您可能无法按照您尝试做的方式做您想做的事情。
但...
您可以使用<div>
并且<span>
只需将其 CSS 设置为:
display: table-row-group;
display: table-header-group;
display: table-footer-group;
display: table-row;
display: table-cell;
display: table-column-group;
display: table-column;
那么就没有孩子的限制了。
您还可以使用更新的自定义内置元素范例,例如<td is="my-td"></td>
:
推荐阅读
- json - 如何将我的 Mapreduce 结果操作存储在 Json 文件中?
- visual-studio-code - 在 VSCode 资源管理器中打开文件夹时,扩展主机意外终止
- tensorflow - 用于回归任务的贝叶斯 CNN
- python - 如何使用美国农业部 API
- reactjs - 使用反应钩子将异步数据作为道具传递
- reactjs - React Hook useEffect 缺少依赖项:'xxx'、'xxx' 和 'xxx'。包括它们或删除依赖数组
- sql - SQL Server 查询返回的数据结构
- node.js - 从 express API 获取图像
- android - Android - 无法查询任务“:app:generateSafeArgsDebug”属性“analyticsService”的值,因为它没有值
- node.js - Axios Incoming Readable stream随机关闭而不触发'close'事件并且它挂在Node中