FileSystemDirectoryHandle:entries() 方法
Baseline 2023Newly available
Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
备注: 此特性在 Web Worker 中可用。
FileSystemDirectoryHandle
接口的 entries()
方法返回一个异步迭代器,用于迭代调用此方法的 FileSystemDirectoryHandle
中的条目的键值对。键值对是一个 [key, value]
形式的数组。
语法
js
entries()
参数
无。
返回值
一个新的包含 FileSystemDirectoryHandle
中每个条目的键值对的异步迭代器。
异常
NotAllowedError
DOMException
-
如果句柄的
PermissionStatus.state
在read
模式下不是'granted'
,则抛出此异常。 NotFoundError
DOMException
-
如果未找到当前条目,则抛出此异常。
示例
使用 for await...of
循环能够简化迭代过程。
js
const dirHandle = await window.showDirectoryPicker();
for await (const [key, value] of dirHandle.entries()) {
console.log({ key, value });
}
规范
Specification |
---|
File System # api-filesystemdirectoryhandle-asynciterable |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
entries |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
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.