phantomjs有类似于node_modules(来自nodejs)吗?
这样我可以使用require('moduleName');
之类的东西来使代码更清晰。
答案 0 :(得分:1)
您可以使用injectJs动态加载幻像脚本。
console.log(phantom.injectJs('./path-to-file.js'));
来自维基
injectJs(filename){boolean}
将指定文件中的外部脚本代码注入Phantom外部空间。如果在当前目录中找不到该文件,则使用libraryPath进行其他查找。如果注入成功,则此函数返回true,否则返回false。