PhantomJS - changeWorkingDirectory



它允許您更改工作目錄,如果成功,則返回 true,否則返回 false。

語法

其語法如下所示 −

fs.changeWorkingDirectory(filepath);

示例

我們來看一個 changeWorkingDirectory 方法的示例。

var fs = require('fs'); 
console.log(fs.workingDirectory);   // prints the location where phantomjs is running 
fs.changeWorkingDirectory("C:\\"); 
console.log(fs.workingDirectory);   // prints C:/ 

以上程式生成以下 輸出

C:/phantomjs/bin 
C:/ 
phantomjs_file_system_module_methods.htm
廣告
© . All rights reserved.