问题
I am looking at using AMP for a page which has a section that gets updated via websockets currently. I assume this isn't possible with AMP, so as a fallback can we use AJAX polling, or can it only be static content?
回答1:
You can't use web sockets or AJAX polling in AMP. However your use case might be better handled with the upcoming amp-live-list component: https://github.com/ampproject/amphtml/issues/2762
回答2:
Only static content. You could add a button to re-direct to a non-AMP JS-based page to do the polling. If you have consistent menus, then the polling page could be equivalent to a pop-up with a return to the AMP page.
回答3:
yes, we can't use ajax in amp page pages but we can try same implementation using amp-list tag
<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>
来源:https://stackoverflow.com/questions/36450831/i-guess-its-not-possible-to-use-web-sockets-can-ajax-polling-be-used-with-amp