Chrome 上的方法:
new PerformanceObserver((entryList) => {
for (const entry of entryList.getEntries()) {
console.log('LCP candidate:', entry.startTime, entry);
}
}).observe({type: 'largest-contentful-paint', buffered: true});
但是 LargestContentfulPaint 在 iOS 上不兼容,有其他方法吗?