- 檔案系統模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 系統模組
- PhantomJS - 屬性
- Web 伺服器模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 其他內容
- 命令列介面
- PhantomJS - 螢幕捕獲
- PhantomJS - 頁面自動化
- PhantomJS - 網路監視
- PhantomJS - 測試
- PhantomJS - REPL
- PhantomJS - 示例
- PhantomJS 有用資源
- PhantomJS - 快速指南
- PhantomJS - 有用資源
- PhantomJS - 討論
PhantomJS - 列表
list 方法返回目錄中存在的所有檔案。
語法
其語法如下 −
var fs = require('fs');
fs.list(path);
範例
以下範例顯示 list 方法的用法。
命令 − phantomjs list.js C:\phantomjs\
var fs = require('fs');
var system = require('system');
var path = system.args[1];
if (fs.isDirectory(path)) {
console.log(fs.list(path));
}
phantom.exit();
上述程式會產生以下 輸出。
.,..,bin,ChangeLog,examples,LICENSE.BSD,README.md,third-party.txt
輸出顯示 PhantomJS 目錄中存在的所有檔案。
phantomjs_file_system_module_methods.htm
廣告