当我显示 div 时,隐藏的 div 内的 amp-img 不显示

amp-img inside a div hidden is not displayed when I display the div

我在 div 中有一个隐藏的 amp-img 元素,当我 select 无线电输入时会显示此 div,但此时图像未显示, 仅当我调整浏览器大小时显示图像。

当我更改 div 的显示时,我需要做什么来显示图像? 我查看了元素amp-img没有事件,怎么办?

谢谢,拉斐尔。

发生这种情况是因为 AMP 页面不像 Angular 和 NodeJS 制作的网站那样具有实时更新功能。这就是为什么您将不得不求助于手动刷新的原因。那是因为AMP页面只是在一定程度上限制了JS。

作为per the docs

Third-party JS likes to use synchronous JS loading. They also like to document.write more sync scripts. For example, if you have five ads on your page, and each of them cause three synchronous loads, each with a 1 second latency connection, you’re in 15 seconds of load time just for JS loading.

AMP pages allow third-party JavaScript but only in sandboxed iframes. By restricting them to iframes, they can’t block the execution of the main page. Even if they trigger multiple style re-calculations, their tiny iframes have very little DOM.