简体   繁体   English

Dom重复动态标头

[英]Dom-repeat dynamic header

I am using Polymer to fetch data from a firebase database and show it on the screen. 我正在使用Polymer从Firebase数据库获取数据并将其显示在屏幕上。 The idea is to get a list of dates and show headers above a date, every time it is a new month. 这个想法是获取日期列表,并在每个新月都显示日期上方的标题。

For example, the following list would be generated (if correctly generated, format of the date is dd/mm/yyyy): 例如,将生成以下列表(如果正确生成,则日期格式为dd / mm / yyyy):

January
01-01-2015
05-01-2015

February
02-02-2015

April
02-04-2015

I have the following code to generate the dates: 我有以下代码来生成日期:

<template is="dom-repeat" items="[[dates]]" as="date">
    <date this-date="[[date]]" class="date"></date>
</template>

I can't find a way to show a header on top of every new month. 我找不到一种在每个新月的顶部显示标题的方法。 dom-repeat appends every new element before the last, so I wasn't able to generate a header in the dom-repeat itself. dom-repeat将每个新元素追加到最后一个元素之前,因此我无法在dom-repeat本身中生成标头。

Could anybody help me with this? 有人可以帮我吗?

I am not sure exactly what is delivering your "dates" property to this bit of code, but I would have tried way (computed property?) or returning a month, with all the dates from the month as an array property of the month object. 我不确定到底是什么将您的“ dates”属性传递给了这段代码,但是我会尝试方法(计算属性?)或返回一个月,并将月中的所有日期作为month对象的array属性。

Then you could have nested templates, the first repeating on the months, the second repeating on the month.dates from the first. 然后,您可能已经嵌套了模板,第一个模板在月份中重复,第二个模板在month.date从第一个重复。 The header would then fit just above the nested template. 标头将恰好位于嵌套模板的上方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM