Polymer 无法显示聚合铁列表的所有项目
我第一次尝试聚合物 索引文件上有以下css:Polymer 无法显示聚合铁列表的所有项目,polymer,polymer-1.0,Polymer,Polymer 1.0,我第一次尝试聚合物 索引文件上有以下css: body { margin: 0; font-family: 'Roboto', 'Noto', sans-serif; line-height: 1.5; height: 100vh; background-color: #eeeeee; } 您可以看到,高度是显式调整的 然后是我对铁名单有意见的页面的CSS: :host {
body {
margin: 0;
font-family: 'Roboto', 'Noto', sans-serif;
line-height: 1.5;
height: 100vh;
background-color: #eeeeee;
}
您可以看到,高度是显式调整的
然后是我对铁名单有意见的页面的CSS:
:host {
padding: 10px;
display: flex;
flex-direction: column;
height: 100vh;
@apply(--paper-font-common-base);
}
iron-list {
flex: 1 1 auto;
--iron-list-items-container: {
max-width: 800px;
margin: auto;
margin-top: 5px;
margin-bottom: 60px;
border-bottom: 1px solid #ddd;
};
}
您还可以看到,我试图使用flexbox作为铁名单的高度
我有一个简单的iron ajax来填充列表。JSON文件中有81条记录
<iron-ajax id="getVehiclesAjax"
url="../data/vehicles.json"
handle-as="json"
auto
on-response="handleVehiclesResponse"
on-error="handleVehiclesError"></iron-ajax>
列表也很简单:
<iron-list id="list" scroll-target="document" items="[[vehicles]]" as="item" selection-enabled>
<template>
<div>
<div class$="[[getClassForItem(item, selected)]]" tabindex$="[[tabIndex]]">
<div class="pad">
<div class="primary-text">[[item.modelo]]</div>
<div class="shortText">[[item.placa]]</div>
<div class="longText">[[item.chassi]]</div>
</div>
</div>
</div>
</template>
</iron-list>
[[item.modelo]]
[[item.placa]]
[[item.chassi]]
预期结果
iron列表应该呈现所有项目,毕竟,大小是在父组件上显式调整的,列表上的scrolltarget是在文档中定义的。此外,该列表在css上具有flexbox设置
实际结果
当我加载页面时,仅呈现27条记录,尽管列表高度与未显示的其余元素相应调整
我尝试添加一个按钮,并将其命名为:this.$.list.fire('iron-resize');
但它不起作用。手动调整窗口大小也没有任何作用
唯一有效的方法是从铁名单中删除此属性:
滚动目标=“文档”
但是如果我删除它,就会有一个滚动条显示铁名单,还有一个滚动条显示文档
我怎样才能解决这个问题?我只需要一个滚动条(文档)和始终呈现的项目…我设法修复了它。通过挖掘代码,我发现了以下属性: 有滚动区域
。。。在封装所有iron页面的应用程序标题布局上。我删除了它,现在一切都按预期进行,滚动时呈现项目,并且只有一个滚动条(在所有者文档上)。那么不将高度设置为“铁名单”吗?如果您不设置高度,它将使用1个滚动条-文档呈现您想要的所有项目。因为我真的不明白你想干什么。也许你想得太多了。我设法解决了这个问题,见下面我的答案。