4

我正在尝试构建一个在单击产品时触发的自动完成输入。输入是允许用户选择一个城市,以便他可以登陆到带有城市上下文的产品详细信息页面。

为了实现这一点,我在单击产品列表中的产品时将产品 url 存储在 amp-state 中,然后当用户选择一个城市时,我想将用户导航到产品 urlcityId作为查询参数。我正在使用amp-listwithamp-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=但是由于没有得到评估,上述内容会引发错误。有没有办法这样做?

4

0 回答 0