E
E
EvilDev2021-04-27 07:49:09
Vue.js
EvilDev, 2021-04-27 07:49:09

How to access variable from external component in NuxtJS?

Hello.
There is a Header.vue site header in which modal authorization windows are located.
There is also a button with a separate component for adding a product to favorites. FavoriteButton.vue
If the user is not logged in, you need to change the variable in the Header from FavoriteButton to show the window.
How can the data() Header be accessed from anywhere in the application?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-04-28
@EvilDev

The same as in Vue, through $refs and props, but this is if you have this single case and there will definitely not be similar situations in the future. Otherwise, it's hell, nonsense and crap, believe me.
And so, with the default configuration of Nuxt.js, you already have Vuex pre-installed, why not write a couple of lines?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question