vendredi 30 juin 2017

How to add slot in repeat dom in polymer 2

i want to create a layout element, so i write the template like this

    <template>
        <div class="row">
            <template is="dom-repeat" items="[[cols]]">
                <div class$="col-[[item]]">
                    <slot id="id[[index]]" name="id[[index]]">no value</slot>
                </div>
            </template>
        </div>
    </template>

and in the html page file, i use this component like this:

    <tcpc-row>
      <span slot="id0">cc id-tcpc-col-0 </span>
      <span slot="id1">cc id-tcpc-col-1 </span>
      <span slot="id1">cc id-tcpc-col-3 </span>
    </tcpc-row>

but i result is not correctly, when i write the template without repeat is ok, like this:

<template>
    <div class="row">
        <div class="col-3">
            <slot name="id0"></slot>
        </div>
        <div class="col-3">
            <slot name="id1"></slot>
        </div>
        <div class="col-3">
            <slot name="id2"></slot>
        </div>
        <!--<template is="dom-repeat" items="[[cols]]">
            <div class$="col-[[item]]">
                <slot id="id[[index]]" name="id[[index]]">no value</slot>
            </div>
        </template>-->
    </div>
</template>

is there have some way to add slot in repeat?




Aucun commentaire:

Enregistrer un commentaire