Amp html 如何制作';搜索框,根据输入字符串'上的get api调用检索的数据显示动态选项列表;比如在amp邮件中选择2
我是AMP电子邮件技术方面的新手,我面临着一个与在搜索框中呈现动态选项相关的问题,该问题使get API请求调用根据输入字符串作为查询,并根据请求检索的数据显示选项列表 我开始知道amp自动完成在amp电子邮件中不起作用,我使用此代码。因此,请考虑这个问题,并提出一个解决这个问题的方法。Amp html 如何制作';搜索框,根据输入字符串'上的get api调用检索的数据显示动态选项列表;比如在amp邮件中选择2,amp-html,amp-email,Amp Html,Amp Email,我是AMP电子邮件技术方面的新手,我面临着一个与在搜索框中呈现动态选项相关的问题,该问题使get API请求调用根据输入字符串作为查询,并根据请求检索的数据显示选项列表 我开始知道amp自动完成在amp电子邮件中不起作用,我使用此代码。因此,请考虑这个问题,并提出一个解决这个问题的方法。 <div> <amp-state id="name"></amp-state> <input id="name-input" place
<div>
<amp-state id="name"></amp-state>
<input id="name-input" placeholder="Search name..." on="input-throttled:AMP.setState({ name: event.value })">
<amp-list layout="fixed-height" height="100" src="https://www.example.com/a/b?q='name'" items=".">
<template type="amp-mustache">
<div>{{name}}</div>
</template>
</amp-list>
</div>
“提供类似以下内容的json数据[{“id”:“1”,“name”:“abc”},{“id”:“2”,“name”:“abd”},”您似乎试图修改amp列表的src
,但电子邮件的amp不允许绑定到src
(此外,您必须在web上的amp中使用[src]
而不是src
)
一个选项是使用带有隐藏输入字段的amp-form
,您可以在调用setState
后立即提交该字段:
<div>
<input id="name-input" placeholder="Search name..." on="input-throttled:AMP.setState({ name: event.value }), suggestions.submit">
<form id="suggestions" method="get" action-xhr="https://www.example.com/a/b">
<input type="hidden" name="q" value="" [value]="name">
<div submit-success>
<template type="amp-mustache">
{{#.}}
<div>{{name}}</div>
{{/.}}
</template>
</div>
</form>
</div>
{{#.}}
{{name}}
{{/.}}
另外请注意,您不需要
,除非您想为您的状态指定一个默认值。谢谢您的回答,我真的很感激。每个字符输入都有请求,情况如下““。实际上,我的站点请求与cors不兼容。我们有没有办法用csrf令牌发出相同的源代码请求,或者我必须做其他事情?。您能指导我完成此操作吗?CORS没有解决方法,您需要确保您的网站发送正确的标题。您好,我已声明如下响应标题:访问控制允许源=*,AMP访问控制允许源=amp@gmail.dev,Access Control Expose Headers=AMP Access Control Allow Source Origin,当它点击请求时,我可以在Inspect element/Network中看到数据,但在屏幕上看不到任何数据,我还提到了提交错误和提交成功,但这其中没有任何一个。请指导我如何进行这项工作?