S
S
szQocks2020-09-01 21:40:33
JavaScript
szQocks, 2020-09-01 21:40:33

How to pass a click event from component #1 to component #2?

There are 2 components, in component #1 - a button, in component #2 a form, there is also validation, but this is not particularly important.
How to pass a click event from component #1 to component #2, or how to check from a child component for a click in the parent?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2020-09-01
@szQocks

In general, if a component is tied to a parent component, then this indicates problems with the architecture.
But if you really need it, you can:
1. subscribe to the events of the parent component by accessing it via this.$parent
https://ru.vuejs.org/v2/guide/components-edge-case...
2. parent component can call the methods of any child it has ref
https://ru.vuejs.org/v2/guide/components-edge-case...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question