2012-10-12 23 views

回答

1

您可以使用injectJs動態加載幻影腳本。

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

從維基

injectJs(文件名){布爾}

從指定的文件到幻影外層空間注入一個外部腳本代碼。如果在當前目錄中找不到該文件,則使用libraryPath進行其他查找。如果注入成功,則此函數返回true,否則返回false。

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

+0

您可以實際使用的NPM包經理phantom.js,它非常甜蜜。 https://github.com/ariya/phantomjs/wiki/API-Reference#function-require – JustEngland

相關問題