FileSystemEntry: fullPath 屬性
FileSystemEntry 介面的只讀 fullPath 屬性會返回一個字串,該字串指定了檔案系統根目錄到由該條目表示的檔案的完整、絕對路徑。
也可以將其視為相對於根目錄的路徑,並在前面加上 "/" 以使其絕對化。
值
指示條目完整路徑的字串。
示例
此示例顯示了一個以檔案系統作為引數的函式;然後,它獲取一個名為 data.json 的檔案的 FileSystemFileEntry,並返回其完整路徑。
js
function gotFileSystem(fs) {
let path = "";
fs.root.getFile(
"data.json",
{ create: true, exclusive: true },
(entry) => {
path = fullPath;
},
handleError(error),
);
return path;
}
顯然,這有些牽強,因為我們知道該檔案的完整路徑是 "/data.json",因為我們剛剛自己查詢過,但這個概念對於您不知道其完整路徑的場景來說仍然適用。
規範
| 規範 |
|---|
| File and Directory Entries API # dom-filesystementry-fullpath |
瀏覽器相容性
載入中…