F
F
faqmanity2017-10-16 16:44:20
Vue.js
faqmanity, 2017-10-16 16:44:20

How to declare a global variable in Vue js and work with it?

App.js has a div class with v-bind:class="{ ' appRootModal': isModal }" and the isModal variable is naturally created. How to work with it in other components. That is, when the modal opens, the isModal variable must also change. I know and use variables about passing variables to components, but here I need to pass them to the main component. As one of the options, use Vuex, but I think everything is much easier to use here. Something like this.$root.isModal = true;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav Nagorny, 2017-10-16
@esvils

You can use VUEX

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question