为了账号安全,请及时绑定邮箱和手机立即绑定

Puppeteer 从 Node 中监听 map.on('load')

Puppeteer 从 Node 中监听 map.on('load')

呼唤远方 2021-10-29 10:54:03
使用 Puppeteer 从 Node 中监听 map.on('load')。(async () => {  const browser = await puppeteer.launch({ headless: false, devtools: true });  const page = await browser.newPage();  function nodeLog(msg) {    console.log(msg);  }  page.on('load', async () => {    await page.evaluate(() => {      window.map.on('load', () => {        console.log("This runs on the index.html js but I do not need that");        nodeLog("WHY IS THIS NOT WORKING??")      })    })  });  await page.goto(`file:${__dirname + '/index.html'}`);})();
查看完整描述

2 回答

?
拉风的咖菲猫

TA贡献1995条经验 获得超2个赞

我还想出了如何返回信息。我重读了文档并得到了一些理解。我不理解上下文。


const nodeLog = msg => console.log;

const msg = await page.evaluate(() => { return 'this is working' });


nodeLog(msg);


查看完整回答
反对 回复 2021-10-29
  • 2 回答
  • 0 关注
  • 289 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信