Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

233
Visualizações
How do I access the dynamic template refs that are nested in Vue 3?

I have a custom list component gcl-list that uses a v-for to render a passed template for each item in an array. Ive nested one of these components in another and am trying to access refs on the children gcl-list-items to then edit the innerHTML but when I access that ref it gives me a string representation of the element which I cant edit the inner HTML. How would I access that childs span and change its innerHTML?

Output to console when logging childItemRefs.value:

Proxy

handler: {get: function, set: function, deleteProperty: function, has: function, ownKeys: function}

target: Array (2)
0 <span data-v-2b58c258>Three.One</span>
1 <span data-v-2b58c258>Three.Two</span>

Code:

<gcl-list :listArray="filteredDropdownItems">
    <template v-slot="itemData">
        <gcl-list-item
                selectable
                :indeterminate="itemData.item.indeterminate"
                :checked="itemData.item.selected"
                :iconStart="itemData.item.iconStart"
                :iconEnd="itemData.item.iconEnd"
                @click.stop
                @click="onItemClick(itemData.item)"
        >
            <span :ref="el => itemRefs[filteredDropdownItems.indexOf(itemData.item)] = el">
                {{ itemData.item.displayValue }}
            </span>
        </gcl-list-item>
        <gcl-list v-if="itemData.item.childItems" :listArray="filteredChildren(itemData.item.childItems)">
            <template v-slot="childItemData">
                <gcl-list-item
                        selectable
                        nested
                        :checked="childItemData.item.selected"
                        :iconStart="childItemData.item.iconStart"
                        :iconEnd="childItemData.item.iconEnd"
                        @click.stop
                        @click="onChildItemClick(childItemData.item, itemData.item)"
                >
                    <span :ref="el => childItemRefs[filteredChildren(itemData.item.childItems).indexOf(childItemData.item)] = el">
                        {{ childItemData.item.displayValue }}
                    </span>
                </gcl-list-item>
            </template>
        </gcl-list>
    </template>
</gcl-list>
    ```


  [1]: https://i.stack.imgur.com/1dFTx.png
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda