FileSystemDirectoryHandle: phương thức keys()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2023.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Web Workers.
Phương thức keys() của giao diện FileSystemDirectoryHandle trả về một bộ lặp bất đồng bộ mới để lặp qua các khóa của các mục bên trong FileSystemDirectoryHandle mà phương thức này được gọi trên đó.
Cú pháp
keys()
Tham số
Không có.
Giá trị trả về
Một bộ lặp bất đồng bộ mới chứa các khóa của từng mục bên trong FileSystemDirectoryHandle.
Ngoại lệ
NotAllowedErrorDOMException-
Được ném ra nếu trạng thái
PermissionStatus.statecủa handle không phải là'granted'ở chế độread. NotFoundErrorDOMException-
Được ném ra nếu mục hiện tại không được tìm thấy.
Ví dụ
Dùng vòng lặp for await...of có thể giúp đơn giản hóa quá trình lặp.
const dirHandle = await window.showDirectoryPicker();
for await (const key of dirHandle.keys()) {
console.log(key);
}
Thông số kỹ thuật
| Specification |
|---|
| File System> # api-filesystemdirectoryhandle-asynciterable> |