我正在使用这个框架制作几个网址的屏幕截图。截图的过程是async的,方法没有提供回调的方式,我想在这个脚本上每次截图的时候都回调:
nightmare = new Nightmare();
urls.forEach(function (url) {
nightmare.goto(url).screenshot(path);
});
nightmare.run(function () {
console.log('finished all');
});
我该怎么做?
最佳答案
我找到了一种方法来执行此操作,使用“use”方法来执行插件。
nightmare = new Nightmare();
urls.forEach(function (url) {
nightmare.goto(url).screenshot(path).use(function () {
console.log('finished one');
});
});
nightmare.run(function () {
console.log('finished all');
});
关于node.js - NightmareJS 截图回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26410157/