Amp html AMP列表-如果API没有响应,如何删除空空间?

Amp html AMP列表-如果API没有响应,如何删除空空间?,amp-html,amp-list,Amp Html,Amp List,我们有一个AMP页面,从服务器上获取3个列表,并将其绑定到客户端。是小提琴还是小提琴 但是,由于输出是动态的,并且我们将高度指定为100,在代码中,第二个列表返回空json,因此我们看到了大量不需要的空空间 获取空列表的代码是: <amp-list width="auto" height="100" layout="fixed-height" src="https://ampbyexample.com/json/examples-empty.json" class="m1">

我们有一个AMP页面,从服务器上获取3个列表,并将其绑定到客户端。是小提琴还是小提琴

但是,由于输出是动态的,并且我们将高度指定为100,在代码中,第二个列表返回空json,因此我们看到了大量不需要的空空间

获取空列表的代码是:

<amp-list width="auto" height="100" layout="fixed-height" src="https://ampbyexample.com/json/examples-empty.json" class="m1">
    <template type="amp-mustache" id="amp-template-id">
      <div><a href="{{url}}">{{title}}</a></div>
    </template>
</amp-list


这在
放大器列表
中目前无法实现。您可以使用。方法是在amp访问
authorization
端点中返回JSON数据。然后,您可以根据数据动态呈现页面上的内容:

<section amp-access="items">
  <template amp-access-template type="amp-mustache">
    {{#items}}
    <div><a href="{{url}}">{{title}}</a></div>
    {{/items}}
  </template>
</section> 

{{{#项目}
{{/items}

有关详细信息,您可以在
中添加
自动调整大小
属性。 从中检查合并的代码。



我也有同样的问题,也许这个小把戏可以帮助其他人,只需编辑样式(高度和显示),这将保持它的高度为你喜欢的,记住这个div需要文本值(不能为空)只要设置它的可见性隐藏,如果你想的话。当未在JavaScript模板上显示JSON值时,它将自动将空白调整为正常。
<style amp-custom>
        amp-list > div.amp-visible{
            display:block;
            height:75px;
        }
        #hideButton{
            visibility: hidden;
        }
</style>    
<amp-list layout="flex-item" src="/static/inline-examples/data/amp-list-data.json">
<div overflow id="hideButton">See more</div>
  <template type="amp-mustache">
    <div class="image-entry">
      <amp-img src="{{imageUrl}}"
        width="100"
        height="75"></amp-img>
      <span class="image-title">{{title}}</span>
    </div>
</template>
</amp-list>

放大器列表>div.amp-visible{
显示:块;
高度:75px;
}
#隐藏按钮{
可见性:隐藏;
}
查看更多
{{title}}

我们想访问cookies,因此我们使用了amp列表。我们如何同时使用amp访问和访问cookie?参考:amp access也支持Cookie。
<style amp-custom>
        amp-list > div.amp-visible{
            display:block;
            height:75px;
        }
        #hideButton{
            visibility: hidden;
        }
</style>    
<amp-list layout="flex-item" src="/static/inline-examples/data/amp-list-data.json">
<div overflow id="hideButton">See more</div>
  <template type="amp-mustache">
    <div class="image-entry">
      <amp-img src="{{imageUrl}}"
        width="100"
        height="75"></amp-img>
      <span class="image-title">{{title}}</span>
    </div>
</template>
</amp-list>