phantomjs有类似于node_modules的东西吗?

时间:2012-10-12 00:30:39

标签: phantomjs

phantomjs有类似于node_modules(来自nodejs)吗?

这样我可以使用require('moduleName');之类的东西来使代码更清晰。

1 个答案:

答案 0 :(得分:1)

您可以使用injectJs动态加载幻像脚本。

  console.log(phantom.injectJs('./path-to-file.js'));

来自维基

injectJs(filename){boolean}

将指定文件中的外部脚本代码注入Phantom外部空间。如果在当前目录中找不到该文件,则使用libraryPath进行其他查找。如果注入成功,则此函数返回true,否则返回false。

https://github.com/ariya/phantomjs/wiki/API-Reference