assignedElements() 特性为 HTMLSlotElement interface returns a sequence of the elements assigned to this slot (and no other nodes). If the flatten option is set to true , it also returns the assigned elements of any other slots that are descendants of this slot. If no assigned nodes are found, it returns the slot's fallback content.

句法

var assignedElements = HTMLSlotElement.assignedElements(options)
					

参数

选项 可选
An object that sets options for the nodes to be returned. The available options are:
  • flatten : A 布尔 indicating whether to return the assigned elements of any available child <slot> elements ( true ) 或不 ( false ). Defaults to false .

返回值

An array of elements.

范例

let slots = this.shadowRoot.querySelector('slot');
let elements = slots.assignedElements({flatten: true});
					

规范

规范 状态 注释
HTML 实时标准
The definition of 'assignedElements()' in that specification.
实时标准

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
assignedElements Chrome 65 Edge 79 Firefox 66 IE 不支持 No Opera Yes Safari ? WebView Android 65 Chrome Android 65 Firefox Android 66 Opera Android Yes Safari iOS ? Samsung Internet Android 9.0

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

元数据

  • 最后修改:
  1. HTMLSlotElement
  2. 特性
    1. 名称
  3. 方法
    1. assignedElements()
    2. assignedNodes()
  4. 事件
    1. slotchange