A
A
Artem Prokhorov2021-12-02 18:16:02
Vue.js
Artem Prokhorov, 2021-12-02 18:16:02

How to reactively track the appearance of the desired key in $refs with v-for?

<div class="profile-slider-circle-void" :ref="'profile-slider-void-' + index"
    :style="{height: $refs['profile-slider-void-' + index][0].clientWidth + 'px'}">
    <div class="profile-slider-plus"></div>
   <span>{{ $store.getters[$store.getters.LANG].Profile.add }}</span>  
</div>

I need to access the value in $refs in tenplate, not in methods. After created, everyone sees the methods, but in the template it just throws an error, and if you put v-if, then it simply does not render it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2021-12-02
@kotcich

Hang a watch on changing the array and update the variable with your style in it (at the same time, you have to wait for the dom to be updated, more details here: https://v3.ru.vuejs.org/ru/api/instance-methods.ht... ).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question