Amp html amp日期倒计时脚本运行正常,但未验证
我正在动态设置amp日期倒计时中的剩余时间:Amp html amp日期倒计时脚本运行正常,但未验证,amp-html,Amp Html,我正在动态设置amp日期倒计时中的剩余时间: <amp-list width="auto" height="620" layout="fixed-height" src="/api/offer/******"> <template type="amp-mustache" id="amp-template-id"> <amp-animation id="hide-timeo
<amp-list width="auto"
height="620"
layout="fixed-height"
src="/api/offer/******">
<template type="amp-mustache" id="amp-template-id">
<amp-animation id="hide-timeout-event" layout="nodisplay">
<script type="application/json">
{
"duration": "0.01s",
"fill": "both",
"selector": "#ampdate",
"keyframes": { "visibility": "hidden"}
}
</script>
</amp-animation>
<amp-date-countdown
id="ampdate"
timeleft-ms="{{{time_left}}}"
layout="fixed-height"
height="150"
on="timeout: hide-timeout-event.start, show-timeout-event.start"
when-ended="stop">
<template type="amp-mustache">
{{{h}}} h {{`{{{m}}} m {{{s}}} s
</template>
</amp-date-countdown>
</template>
</amp-list>
{
“持续时间”:“0.01秒”,
“填充”:“两者”,
“选择器”:“#ampdate”,
“关键帧”:{“可见性”:“隐藏”}
}
{{h}}h{{{{{m}}m{{{s}}}s
代码运行完全正常,但未进行验证,并引发两个错误:
标记“amp date countdown”中的属性“timeleft ms”设置为“{{{time_left}}}}”,其中包含未替换的胡须模板语法
标记“template”不能作为标记“template”的后代出现
我不知道我做错了什么,因为这完全符合预期。回答我自己的问题: 将模板移到amp列表之外,并通过amp date倒计时中的id调用它。并消除了第一个错误。第二个错误同样简单。amp-date-倒计时没有理由接受未替换的参数。从
{{{***}}到{***}
的简单更改可更正此错误。以下代码起作用并验证:
<template type="amp-mustache" id="timer">
{{{h}}} h {{`{{{m}}} m {{{s}}} s
</template>
<amp-list width="auto"
height="620"
layout="fixed-height"
src="/api/offer/******">
<template type="amp-mustache" id="amp-template-id">
<amp-animation id="hide-timeout-event" layout="nodisplay">
<script type="application/json">
{
"duration": "0.01s",
"fill": "both",
"selector": "#ampdate",
"keyframes": { "visibility": "hidden"}
}
</script>
</amp-animation>
<amp-date-countdown
id="ampdate"
timeleft-ms="{{time_left}}"
layout="fixed-height"
height="150"
on="timeout: hide-timeout-event.start, show-timeout-event.start"
when-ended="stop"
template="timer">
</amp-date-countdown>
</template>
</amp-list>
{{h}}h{{{{{m}}m{{{s}}}s
{
“持续时间”:“0.01秒”,
“填充”:“两者”,
“选择器”:“#ampdate”,
“关键帧”:{“可见性”:“隐藏”}
}