【问题标题】:Determining cumulative layout shift when attributed node is null确定属性节点为空时的累积布局偏移
【发布时间】:2021-03-05 20:14:48
【问题描述】:

我正在尝试减少网站上的 CLS(累积布局偏移)。使用 Google 的 webvitals JS 库,我看到 CLS 的最大来源之一是下面,它的节点为“null”,导致布局转移。有谁知道如何解决这个问题?如果导致转移的节点为空,我将如何更新 CSS 或 HTML 以防止这种转移?

sources: Array(1)
0: LayoutShiftAttribution
currentRect: DOMRectReadOnly {x: 0, y: 0, width: 0, height: 0, top: 0, …}
node: null
previousRect: DOMRectReadOnly {x: 0, y: 0, width: 375, height: 329, top: 0, …}
__proto__: LayoutShiftAttribution

【问题讨论】:

    标签: core-web-vitals cumulative-layout-shift


    【解决方案1】:

    我自己目前正在研究这个问题,我使用很多加载框架来通知用户内容正在加载,一旦获取内容,我认为它们变为空,它们本质上是 DOM 节点,已被替换某种方式。

    【讨论】:

      猜你喜欢
      • 2020-10-31
      • 2021-09-18
      • 2021-05-15
      • 2021-05-28
      • 1970-01-01
      • 1970-01-01
      • 2020-12-31
      • 2017-07-17
      • 1970-01-01
      相关资源
      最近更新 更多