Пожалуйста, попробуйте импортировать АМП-лист и усилитель-усов компоненты в заголовке, более подробная информация приведена в документе
ампер-список компонент извлекает динамического содержимого из CORS JSON и отображает его с помощью прилагаемого шаблона.
<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.1.js"></script>
<script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></script>
создать демо-версию для этого. Ниже мои детали шаги:
1. Опубликовано Web App с страницы AMP
2. Включите CORS для веб-приложения в Azure Portal.
3. Попробуйте просмотреть страницу из браузера
AMP код страницы:
<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
<link rel="canonical" href="https://ampbyexample.com/components/amp-list/">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-boilerplate>
body {
-webkit-animation: -amp-start 8s steps(1,end) 0s 1 normal both;
-moz-animation: -amp-start 8s steps(1,end) 0s 1 normal both;
-ms-animation: -amp-start 8s steps(1,end) 0s 1 normal both;
animation: -amp-start 8s steps(1,end) 0s 1 normal both;
}
@-webkit-keyframes -amp-start {
from {
visibility: hidden;
}
to {
visibility: visible;
}
}
@-moz-keyframes -amp-start {
from {
visibility: hidden;
}
to {
visibility: visible;
}
}
@-ms-keyframes -amp-start {
from {
visibility: hidden;
}
to {
visibility: visible;
}
}
@-o-keyframes -amp-start {
from {
visibility: hidden;
}
to {
visibility: visible;
}
}
@keyframes -amp-start {
from {
visibility: hidden;
}
to {
visibility: visible;
}
}
</style>
<noscript>
<style amp-boilerplate>
body {
-webkit-animation: none;
-moz-animation: none;
-ms-animation: none;
animation: none;
}
</style></noscript>
<style amp-custom>
amp-list {
margin-left: 16px;
}
.list-overflow {
position: absolute;
bottom: 0;
right: 0;
}
</style>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.1.js"></script>
<script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></script>
</head>
<body>
<amp-list width=auto
height=100
layout=fixed-height
src="https://my.azurewebsites.net/test.json"
template="amp-template-id"
>
</amp-list>
<template id="amp-template-id" type="amp-mustache">
<div>
<p>FirstName : {{firstName}}</p>
</div>
</template>
</body>
</html>
test.json:
{
"items": [
{
"firstName": "tom",
"lastName": "test"
},
{
"firstName": "tom1",
"lastName": "test"
},
{
"firstName": "tom2",
"lastName": "test"
}
]
}
Благодарим вас за подробную помощь. Теперь он работает. Еще одна вещь, которую я должен был добавить. В web.config: < "JSON" mimeMap FileExtension = MIMETYPE = "приложения/JSON" /> staticContent> –
vishnu
Ранее я поставил «HTTPS : //my.azurewebsites.net "в CORS. Это тоже не должно работать? Я имел в виду вместо «*». – vishnu
Пожалуйста, попробуйте также добавить '* .ampproject.org' в портал Azure для замены' * '. Подробнее о запросах CORS в AMP, пожалуйста, обратитесь к [документу] (https://github.com/dvoytenko/amphtml/blob/master/spec/amp-cors-requests.md). –