PhantomJS require() a relative path

后端 未结 5 531
情书的邮戳
情书的邮戳 2021-02-04 03:07

In a PhantomJS script I would like to load a custom module but it seems relative paths do not works in PhantomJS ?

script.js:

var foo = require(\'./scrip         


        
5条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-04 03:55

    have you tried to use injectJs(filename)

    excerpt form PhantomJS documentation:

    Injects external script code from the specified file. If the file can not be found in the current directory, libraryPath is used for additional look up.

    This function returns true if injection is successful, otherwise it returns false.

提交回复
热议问题