首页 > 为什么在phantomjs的page.onLoadFinished里面拿不到页面中的jquery对象

为什么在phantomjs的page.onLoadFinished里面拿不到页面中的jquery对象

为什么在phantomjs的page.onLoadFinished里面拿不到页面中的jquery对象,页面中有jq这个库。

var page = require('webpage').create();

page.onLoadFinished = function() {
    console.log($);// 提示undefined,换成console.log(window.$)提示也是undefined
}

page.open(someurl)

请问下phantomjs的应用场景


这个回调的scope不是网页。
可以用page.evaluate()

page.onLoadFinished = function() {
    page.evaluate(function() {
        console.log($);
    });
}
【热门文章】
【热门文章】