首页 > 解决方案 > amp-list src url 未获取数据

问题描述

我在 twig 文件中使用 amp-list 来创建选择下拉列表。但是树枝文件为{{#countries}}行 抛出了一个错误Unexpected character "#"。当此行被注释掉时,url 会正确获取数据。请看下面的代码:-

<section class="card">
        <h2>Country</h2>
        <amp-list src="https://ampbyexample.com/json/cart.json" layout="fixed-height" height="80" >
            <template type="amp-mustache">
                <label for="country">Countries</label>
                <select id="country"
                        on="
      change:
        AMP.setState({
          countries: dropdown.items[0].countries.filter(x => x.profileTitle == event.value)[0]
        })">
                    <option value="">Choose a country</option>
                    {{#countries}}
                    <option value="{{name}}">{{name}}</option>
                    {{/countries}}
                </select>
            </template>
        </amp-list>
    </section>

我应该在 amp-list 中添加一些东西来告诉它等到数据被获取还是 {{#countries}} 模式在 twig 中不可用?非常感谢任何帮助。提前致谢。

标签: twigamp-list

解决方案


推荐阅读