我是amp的新手,并试图建立这个页面,在那里我会从api中获取一些项目,然后在amp-list中呈现其响应。在单击此列表中的任何项目时,我希望访问其价格并显示它。在AMP.setState({selectedItemPrice:?})中应该写些什么?
以下是body标记代码片段
<amp-list height=200 src="https://amp.gmail.dev/playground/public/ssr_amp_list">
<template type="amp-mustache">
<div tabIndex="{{id}}" role="button" class="title" on="tap:AMP.setState({selectedItemPrice: ?????})">{{name}}</div>
</template>
</amp-list>
<p [text]="selectedItemPrice">This is price of product</p>
我尝试使用事件对象,但仍然无法使其工作
发布于 2019-07-04 05:29:01
我正要写一个回复,注意到你已经回复了,只是作为一个评论。是的,您需要在代码中放置{{price}}而不是?????,以便模板注入当前行的价格。然后它就起作用了。
<amp-list height=200 src="https://amp.gmail.dev/playground/public/ssr_amp_list">
<template type="amp-mustache">
<div tabIndex="{{id}}" role="button" class="title" on="tap:AMP.setState({selectedItemPrice: {{price}} })">{{name}}</div>
</template>
</amp-list>https://stackoverflow.com/questions/56549852
复制相似问题