S
S
svilkov872019-03-24 20:30:25
Vue.js
svilkov87, 2019-03-24 20:30:25

Get clientWidth Vue?

Hello.
Piece of code:

<template>
  <div class="block">
    <div class="block__child">test</div>
  </div>
</template>

Is there a way for vue to get the width of block_child ?
I have tried console.log( this ); And I found $el.children[1].clientWidth
this approach extremely undesirable, because the template may have other blocks in the neighborhood. And the index will not be [1], but some other one.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alex, 2019-03-24
@svilkov87

  • $el.querySelector('.block__child')
  • refs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question