我正在尝试构建一个自动完成输入,该输入在单击产品时触发。输入是允许用户选择城市,以便他可以使用城市上下文登录到产品详细信息页面。
为实现此目的,我在点击产品列表中的产品时将产品网址存储为放大状态,然后当用户选择城市时,我想将用户导航到产品网址cityId
作为查询参数。我正在使用amp-list
与amp-mustache
进行自动填充。
代码:
<form action="//localhost/search/" id="citysuggest-form" on="submit:autosuggest-list.hide" target="_top" novalidate="" hidden>
<input autocomplete="off" i name="bysearch" on="input-debounced:AMP.setState({city_autosuggest: {autosuggest: event.value}}),autosuggest-list.show" placeholder="Search city..." required="" value="" type="text" [value]="autosuggest|| ''" class="search__form" autofocus>
<span class="close" on="tap:autosuggest-list.hide,city__search.hide" role="button" tabindex="0">×</span>
</form>
<amp-selector layout="container" on="select:AMP.navigateTo(url='//localhost'+(selectProductUrl || '')+'?cityId='+event.targetOption)">
<amp-list [src]="'//localhost/api/v2/autocomplete-amp/city/?record=5&term=' + (city_autosuggest.autosuggest || '')" height="110" hidden="" id="autosuggest-list" layout="responsive" src="//localhost/api/v2/autocomplete-amp/city/?record=5&term=" width="200" class="search__result-list">
<template type="amp-mustache">
<div class="search__result" option='{{payload.cityId}}' role="option" tabindex="0">{{result}}</div>
</template>
</amp-list>
</amp-selector>
但是由于url=
没有得到评估,上面引发了错误。有办法吗?