猿问

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

使用 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'}`);


})();


呼唤远方
浏览 290回答 2
2回答

拉风的咖菲猫

我还想出了如何返回信息。我重读了文档并得到了一些理解。我不理解上下文。const nodeLog = msg => console.log;const msg = await page.evaluate(() => { return 'this is working' });nodeLog(msg);
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答