J
J
JuJes2020-09-11 09:51:32
Vue.js
JuJes, 2020-09-11 09:51:32

How to pass value from one vue to another?

Good afternoon! Essence of the question:
There are three vue:
SomeTree (1)
SomeTreeItem (2)
SomeTreeItemContextMenu (3)

In (2) there is a method that returns a value that needs to be passed to (3), while (3) can only be reached through (1 )

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Korotenko, 2020-09-11
@firedragon

Ultimate methods:
localStorage
window.youVar
And so specify.
If this is a single VUE instance, then just use the data of the main component, or store, or EventBus
https://medium.com/@andrejsabrickis/https-medium-c...

A
Aetae, 2020-09-12
@Aetae

If these are just random components, then the method can be obtained through refand passed to another component through props. Only "pass methods" - not in the ideology of Vue.
If it is necessary to call the action of another from one component, the first one should call the event ( $emit) and the parent component should catch it ( @event) and perform the desired action.
However, if there is a container element in which there is a complex and / or recursive nesting and which combines the functionality of children, such a component can pass ( provide) an object common to all children, who will receive it ( inject) and use it together.

V
vItalIyIrtlach, 2020-09-15
@w13vitaliy

postMessage it seems it is possible? If anything, correct mench

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question