HTMLSlotElement

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

Shadow DOM API 的接口 HTMLSlotElement 使其能够访问到 HTML 元素 <slot> 的名字和分配的节点

属性

HTMLSlotElement.name

DOMString: 可以用来设置和获取 slot 的名字

方法

HTMLSlotElement.assignedNodes() (en-US)

Returns the sequence of elements assigned to this slot, or alternatively the slot's fallback content.

规范

Specification
HTML Standard
# htmlslotelement

浏览器的兼容性

BCD tables only load in the browser