FileSystemDirectoryHandle:values() 方法
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2023年3月.
备注: 此特性在 Web Worker 中可用。
FileSystemDirectoryHandle
接口的 values()
方法返回一个异步迭代器,用于迭代调用此方法的 FileSystemDirectoryHandle
中的条目的值。
语法
js
values()
参数
无。
返回值
一个新的包含 FileSystemDirectoryHandle
中每个条目的句柄的异步迭代器。
异常
NotAllowedError
DOMException
-
如果句柄的
PermissionStatus.state
在read
模式下不是'granted'
,则抛出此异常。 NotFoundError
DOMException
-
如果未找到当前条目,则抛出此异常。
示例
使用 for await...of
循环能够简化迭代过程。
js
const dirHandle = await window.showDirectoryPicker(); for await (const value of dirHandle.values()) { console.log(value); }
规范
Specification |
---|
File System> # api-filesystemdirectoryhandle-asynciterable> |
浏览器兼容性
Loading…