Answer the question
In order to leave comments, you need to log in
Using Vue (vuex) global variables in multiple components, how to optimize?
Hey!
There is a web application, the main page of which consists of several large tab-switched components, which, in turn, have a number of child modules.
The vuex store has a global variable (String) activeTab
that is responsible for the content displayed on the main page of the application.
import {mapGetters} from "vuex";
....
computed: {
...mapGetters({
.....
activeTab: "getActiveTab",
.....
})
},
v-show=""
and :class=""
in both components.div
с условием v-if="activeTab == '...'",
, то переключение осуществляется 2-3 секунды.$parent.activeTab
- не помогло.this.$store.commit('setActiveTab', key);
Answer the question
In order to leave comments, you need to log in
Working with vuex has nothing to do with it. You yourself said that these are large components.
v-show only does display: none/block
v-if removes the markup from the DOM and redraws it, which is way more expensive than just hiding the
block make the condition for creating the body of the tab through v-if, and hide/show do it through v-show
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question