需要在下面的代码中添加什么参数才能获得Desktop的性能分数?
const fs = require('fs');
const lighthouse = require('lighthouse');
const chromeLauncher = require('chrome-launcher');
const log = require('lighthouse-logger');
(async () => {
log.setLevel('info');
const chrome = await chromeLauncher.launch({ chromeFlags: ['--headless'] });
const options = { output: 'json', onlyCategories: ['performance'], port: chrome.port };
const runnerResult = await lighthouse('url', options);
// `.report` is the HTML report as a string
const reportJson = runnerResult.report;
fs.writeFileSync('lhreport.json', reportJson);
// `.lhr` is the Lighthouse Result as a JS object
console.log('Report is done for', runnerResult.lhr.finalUrl);
console.log('Performance score was', runnerResult.lhr.categories.performance.score * 100);
await chrome.kill();
})();发布于 2020-11-23 19:28:58
在options对象中添加以下属性:
emulatedFormFactor: "desktop"const options = { output: 'json', emulatedFormFactor:"desktop", vonlyCategories: ['performance'], port: chrome.port };https://stackoverflow.com/questions/62713535
复制相似问题