FileSystemDirectoryHandle:keys() 方法

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

安全上下文: 此项功能仅在一些支持的浏览器安全上下文(HTTPS)中可用。

FileSystemDirectoryHandle 接口的 keys() 方法返回一个异步迭代器,用于迭代调用此方法的 FileSystemDirectoryHandle 中的条目的键。

语法

js
FileSystemDirectoryHandle.keys()

参数

无。

返回值

一个新的包含 FileSystemDirectoryHandle 中每个条目的键的异步迭代器。

示例

使用 for await...of 循环能够简化迭代过程。

js
const dirHandle = await window.showDirectoryPicker();

for await (const key of dirHandle.keys()) {
  console.log(key);
}

规范

Specification
File System Standard
# api-filesystemdirectoryhandle-asynciterable

浏览器兼容性

BCD tables only load in the browser

参见