使用 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 回答
![?](http://img1.sycdn.imooc.com/545863b500014e4602200220-100-100.jpg)
拉风的咖菲猫
TA贡献1995条经验 获得超2个赞
我还想出了如何返回信息。我重读了文档并得到了一些理解。我不理解上下文。
const nodeLog = msg => console.log;
const msg = await page.evaluate(() => { return 'this is working' });
nodeLog(msg);
添加回答
举报
0/150
提交
取消