FileSystemHandle: thuộc tính name

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.

Thuộc tính chỉ đọc name của giao diện FileSystemHandle trả về tên của mục nhập được handle biểu diễn.

Giá trị

Một chuỗi.

Ví dụ

Hàm sau cho phép người dùng chọn một file từ bộ chọn file và lấy thuộc tính name.

js
// lưu tham chiếu tới file handle của chúng ta
let fileHandle;

async function getFile() {
  // mở bộ chọn file
  [fileHandle] = await window.showOpenFilePicker();

  const fileName = fileHandle.name;
}

Thông số kỹ thuật

Thông số kỹ thuật
File System
# ref-for-dom-filesystemhandle-name①

Tương thích trình duyệt

Xem thêm