0👍
Component
<template>
<p v-if="showcart">Show</p>
</template>
<script>
import { mapState } from 'vuex';
computed: (state) => {
showCart: state.cart.showCart
}
methods: {
showCartIcon() {
this.$store.dispatch('cart/show', true)
}
}
</script>
Now in your module/Cart.js
const state = () => ({
showCart: false,
})
const actions = {
show({commit}) {
commit('showcartMt', true)
}
}
const mutations = {
showcartMt(state, toggle) {
state.showCart = toggle;
}
}
Source:stackexchange.com