例:ui
"use strict"; const fs = require("fs"); const path = require("path"); //獲取當前文件所在的絕對路徑 let filepath = path.resolve(); fs.readdir(filepath, "utf-8", function(err, files){ if(err) { console.log(err); } else { console.log(files); } });
注:第二個參數不寫的話默認爲 "utf-8"spa