【发布时间】:2018-06-25 09:45:06
【问题描述】:
我正在考虑将 AMP 用于具有当前通过 websockets 更新的部分的页面。我认为这对于 AMP 是不可能的,所以作为后备我们可以使用 AJAX 轮询,还是只能是静态内容?
【问题讨论】:
标签: amp-html
我正在考虑将 AMP 用于具有当前通过 websockets 更新的部分的页面。我认为这对于 AMP 是不可能的,所以作为后备我们可以使用 AJAX 轮询,还是只能是静态内容?
【问题讨论】:
标签: amp-html
您不能在 AMP 中使用网络套接字或 AJAX 轮询。 但是,使用即将推出的 amp-live-list 组件可能会更好地处理您的用例:https://github.com/ampproject/amphtml/issues/2762
【讨论】:
仅静态内容。您可以添加一个按钮以重定向到基于非 AMP JS 的页面以进行轮询。如果您有一致的菜单,那么投票页面可能相当于一个返回 AMP 页面的弹出窗口。
【讨论】:
是的,我们不能在 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>
【讨论】: