我正在实施PerformanceObserver来追踪'first-paint'& '第一contentful漆'。
const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
if (typeof(Storage) !== 'undefined') {
if (entry.name === 'first-paint') {
localStorage.setItem(rumMetrics.RUM_METRICS_FIRST_PAINT, entry.startTime);
}
else if (entry.name === 'first-contentful-paint') {
localStorage.setItem(rumMetrics.RUM_METRICS_FIRST_CONTENTFUL_PAINT, entry.startTime);
}
}
else {
console.log('local storage is not supported here. RUM metrics won\'t be recorded.');
}
}
});
observer.observe({ entryTypes: ['paint'] });
这在Chrome 中非常有效,但在Firefox中引发错误。
TypeError: The expression cannot be converted to return the specified type. (line: observer.observe({ entryTypes: ['paint'] });)
答案 0 :(得分:3)
更新-1:2018年4月20日
Mozilla已经确认了这个错误,它也正在影响FF61 NIGHT
原始答案
确认即使在开发人员版本中这也是一个错误。
以下是相同
的错误