How do I run a function on a different component with vuex (non parent/child components)
I have 2 non parent/child components. I'd like to run a function on component A by clicking a button on component B. I know that the eventbus is a solution but because I am already using Vuex I would like to do it the Vuex way but could not find an example on the internet.
Have component A mutate some state that component B is watching. When component B see's a change to that state, run your function.
The mutation could be as simple as flipping a boolean or incrementing a number. Anything to trigger the watch in the other component.
Here is how to setup the watch: https://stackoverflow.com/a/44347195/1409310
ReferenceURL : https://stackoverflow.com/questions/58136479/how-do-i-run-a-function-on-a-different-component-with-vuex-non-parent-child-com
'source' 카테고리의 다른 글
| uppload_files true이지만 edit_post false로 사용자 지정 사용자 역할을 워드프레스합니다. 미디어를 삭제하고 편집하려면 어떻게 해야 합니까? (0) | 2023.09.21 |
|---|---|
| if/-then-else 문에 행을 삽입하는 중 (0) | 2023.09.21 |
| wp_enqueue_script로 Google 지도 API 로드 중 (0) | 2023.09.21 |
| Angularjs에서 ng-messages로 서버 오류를 표시하는 방법 (0) | 2023.09.21 |
| Wocommerce 사용자 정의 제품 텍스트 (0) | 2023.09.21 |