D
D
dark_king_132020-01-16 21:38:50
Vue.js
dark_king_13, 2020-01-16 21:38:50

How to run method of one component from another component?

I have 2 components, one contains a filter, the other contains a request to the server using the filter.
I need a button click on the filter panel to trigger a search function in another component.
I tried using an eventEmitter to pass data. It works fine in other components, but something goes wrong here. Here is the code:
5e20ac074ffee649502985.png
In the ProjectList component, I tried putting an eventEmitter on both created and mounted, nothing works.
In the current circumstances, I have to go to another page after selecting a filter and then return to get data on a new question

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2020-01-16
@dark_king_13

In general, if you follow the principles of Vue design, then the filter state should be put in a separate Vuex module. And then you can declaratively access its state in other components..

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question