猿问

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

为什么在phantomjs的page.onLoadFinished里面拿不到页面中的jquery对象,页面中有jq这个库。varpage=require('webpage').create();
page.onLoadFinished=function(){
console.log($);//提示undefined,换成console.log(window.$)提示也是undefined
}
page.open(someurl)
弑天下
浏览 389回答 2
2回答

跃然一笑

这个回调的scope不是网页。可以用page.evaluate()page.onLoadFinished=function(){page.evaluate(function(){console.log($);});}

天涯尽头无女友

请问下phantomjs的应用场景
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答