PhantomJS remove删除 该方法用于删除指定的文件。 语法 其语法如下 – var fs = require('fs'); fs.remove(path); JavaScriptCopy 示例 以下示例展示了 remove 方法的工作原理。 命令 - phantomjs remove.js test.txt var fs = require('fs'); var system = require('system'); var path = system.args[1]; var md = fs.isFile(path); console.log("File is present : "+fs.isFile(path)); console.log("Removing file "+path); var rd = fs.remove(path); console.log("File is present "+fs.isFile(path)); phantom.exit(); JavaScriptCopy 以上程序生成了以下 输出 。 File is present: true Removing file test.txt File is present false JavaScriptCopy