.inject() 和 .goto() 方法在噩梦中不起作用



我已经用Nightmare刮了几天了,我的问题是加载页面并使用.inject()包含jQuery我写了这段代码;

const Nightmare = require ('nightmare');
var nightmare = new Nightmare ();
nightmare
    .goto(url)
    .inject('js', __dirname + /jquery.min.js')
    .evaluate(fn(){
               /*I need to extract some information from the page but when 
               I try to use the DOM object or the jQuery's '$' it shows 
               me an error saying that no document is defined*/
     })
    .wait(500);

PHPstorm(我用来用JS和PHP编程的IDE(标记.goto().inject()并删除警告消息unresolved function or method .goto()unresolved function or method .inject()

我需要做什么来加载页面?也许没有足够的时间?

我认为

.inject('js', __dirname + /jquery.min.js')' 

应该是

.inject('js', __dirname + '/jquery.min.js')'

您缺少报价

最新更新