使用puppeter生成pdf,官方文档的例子都是使用async,await写的,但是项目的node版本是6.6,不支持async这种写法,请问下面这段代码如何改成promise?
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('http://www.baidu.com', {waitUntil: 'networkidle2'});
await page.pdf({
path: 'hn.pdf',
format: 'A4'
});
await browser.close();
})();
试下能运行不,大概就是这个思路吧,
await
改成Promise
调用