【问题标题】:I guess it's not possible to use web sockets, can AJAX polling be used with AMP?我想不可能使用网络套接字,AJAX 轮询可以与 AMP 一起使用吗?
【发布时间】:2018-06-25 09:45:06
【问题描述】:

我正在考虑将 AMP 用于具有当前通过 websockets 更新的部分的页面。我认为这对于 AMP 是不可能的,所以作为后备我们可以使用 AJAX 轮询,还是只能是静态内容?

【问题讨论】:

    标签: amp-html


    【解决方案1】:

    您不能在 AMP 中使用网络套接字或 AJAX 轮询。 但是,使用即将推出的 amp-live-list 组件可能会更好地处理您的用例:https://github.com/ampproject/amphtml/issues/2762

    【讨论】:

    • 我做了一些挖掘,发现了这个问题。当它准备好时,我肯定会研究的东西。谢谢。
    【解决方案2】:

    仅静态内容。您可以添加一个按钮以重定向到基于非 AMP JS 的页面以进行轮询。如果您有一致的菜单,那么投票页面可能相当于一个返回 AMP 页面的弹出窗口。

    【讨论】:

      【解决方案3】:

      是的,我们不能在 amp 页面页面中使用 ajax,但我们可以使用 amp-list 标签尝试相同的实现

          <amp-list src="http://localhost:3000/comments" 
              [src]="productsState.items" 
              width="320"
              height="144"
              [height]="productsState.items.length * 24"
              class="m1">
      <template type="amp-mustache">
        <strong>Product</strong>: {{name}}
        <strong>Price</strong>: ${{price}}
      </template>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-05-16
        • 2014-11-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-21
        相关资源
        最近更新 更多