V
V
Vyacheslav2021-10-08 11:14:06
Vue.js
Vyacheslav, 2021-10-08 11:14:06

Vue 3 - how to read data from a slave?

Good afternoon. There is a desire but no idea how to read data from child components.

For example, there is such a thing

<parent>
       <child></child>
       <child></child>
</parent>


There is a computed variable in child , I need to read it from parent. I don’t want to hang anything on child, not any ref. I want it straight.

Are there any ideas

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ice, 2021-10-08
@IceRD

1) Throw a callback
2) Use $emit from child
3) store data globally (use vuex)

A
Anton Anton, 2021-10-08
@Fragster

Do you want vuex? Make a separate state object with reactive api and use it in both parent and child

V
Vyacheslav, 2021-10-08
@abalduy

Thanks everyone, I figured it out myself.

<parent >
       <child ref="row-1"></child>
       <child ref="row-2"></child>
</parent>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question