HTML
<slot>
element
—part of the
Web 组件
technology suite—is a placeholder inside a web component that you can fill with your own markup, which lets you create separate DOM trees and present them together.
| 内容类别 | 流内容 , 措词内容 |
|---|---|
| 准许内容 | Transparent |
| 事件 |
slotchange
|
| Tag omission | None, both the starting and ending tag are mandatory. |
| Permitted parents | Any element that accepts 措词内容 |
| Implicit ARIA role | 无对应角色 |
| Permitted ARIA roles |
No
role
permitted
|
| DOM 接口 |
HTMLSlotElement
|
此元素包括 全局属性 .
名称
The slot's name.
<slot>
element with a
名称
属性。
<template id="element-details-template">
<style>
details {font-family: "Open Sans Light", Helvetica, Arial, sans-serif }
.name {font-weight: bold; color: #217ac0; font-size: 120% }
h4 {
margin: 10px 0 -8px 0;
background: #217ac0;
color: white;
padding: 2px 6px;
border: 1px solid #cee9f9;
border-radius: 4px;
}
.attributes { margin-left: 22px; font-size: 90% }
.attributes p { margin-left: 16px; font-style: italic }
</style>
<details>
<summary>
<code class="name"><<slot name="element-name">NEED NAME</slot>></code>
<i class="desc"><slot name="description">NEED DESCRIPTION</slot></i>
</summary>
<div class="attributes">
<h4>Attributes</h4>
<slot name="attributes"><p>None</p></slot>
</div>
</details>
<hr>
</template>
注意 : You can see this complete example in action at element-details (see it running live ). In addition, you can find an explanation at Using templates and slots .
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of '<slot>' in that specification. |
实时标准 | |
|
DOM
The definition of 'Slots' in that specification. |
实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
slot
|
Chrome 完整支持 53 | Edge 完整支持 79 |
Firefox
完整支持
63
|
IE 不支持 No | Opera 完整支持 40 | Safari 完整支持 10 | WebView Android 完整支持 53 | Chrome Android 完整支持 53 |
Firefox Android
完整支持
63
|
Opera Android 完整支持 41 | Safari iOS 完整支持 10 | Samsung Internet Android 完整支持 6.0 |
名称
|
Chrome 完整支持 53 | Edge 完整支持 79 |
Firefox
完整支持
63
|
IE 不支持 No | Opera 完整支持 40 | Safari 完整支持 10 | WebView Android 完整支持 53 | Chrome Android 完整支持 53 |
Firefox Android
完整支持
63
|
Opera Android 完整支持 41 | Safari iOS 完整支持 10 | Samsung Internet Android 完整支持 6.0 |
完整支持
不支持
用户必须明确启用此特征。
<content>
<shadow>
<slot>
<template>