FileSystemDirectoryHandle:keys() 方法
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
接口的 keys()
方法返回一个异步迭代器,用于迭代调用此方法的 FileSystemDirectoryHandle
中的条目的键。
语法
js
keys()
参数
无。
返回值
一个新的包含 FileSystemDirectoryHandle
中每个条目的键的异步迭代器。
异常
NotAllowedError
DOMException
-
如果句柄的
PermissionStatus.state
在read
模式下不是'granted'
,则抛出此异常。 NotFoundError
DOMException
-
如果未找到当前条目,则抛出此异常。
示例
使用 for await...of
循环能够简化迭代过程。
js
const dirHandle = await window.showDirectoryPicker();
for await (const key of dirHandle.keys()) {
console.log(key);
}
规范
Specification |
---|
File System # api-filesystemdirectoryhandle-asynciterable |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
keys |
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.