vuex-modules

Need multiple instances of Vuex module for multiple Vue instances

十年热恋 提交于 2021-02-08 10:30:47
问题 I'm integrating Vue onto a site for forms, which means I have to create several instances of that Vue application if there are multiple forms on the page. All instances share the same Vuex store. I created a Vuex module so that each Vue instance could have it's own local state. My main goal is to prevent one Vue instance from updating the state of another Vue instance. Here's my Vuex module export default { state() { return { stateObj: {...} } } } Creating my Vuex instance: export default new

Need multiple instances of Vuex module for multiple Vue instances

霸气de小男生 提交于 2021-02-08 10:30:26
问题 I'm integrating Vue onto a site for forms, which means I have to create several instances of that Vue application if there are multiple forms on the page. All instances share the same Vuex store. I created a Vuex module so that each Vue instance could have it's own local state. My main goal is to prevent one Vue instance from updating the state of another Vue instance. Here's my Vuex module export default { state() { return { stateObj: {...} } } } Creating my Vuex instance: export default new

Specify Vuex Store To Use In Component

巧了我就是萌 提交于 2021-01-29 07:26:28
问题 I have modularized my Vuex store and need child-components to be able to access data/use the same stores as their parent component. Here's what I've tried: <!-- ParentOne.vue --> <template> <div> <child-component vuex-store="services/opportunities" /> </div> </template> <script> import ChildComponent from '@/components/services/child-components/ChildComponent'; import { mapActions, mapState, mapGetters } from 'vuex'; export default { components: { 'child-component': ChildComponent, },

NuxtServerInit not working on Vuex module mode - Nuxt.js

那年仲夏 提交于 2020-08-27 06:48:06
问题 NuxtServerInit is not working on initial page render on nuxt js vuex module mode. But it works on Classic mode. Following code is the flow I used. My api call api/CategoryApi.js import axios from 'axios'; const HEADERS = { Accept: 'application/json' }; export default { getCategory(payload) { return axios.get(`${process.env.apiUrl}/category`, { payload, headers: HEADERS }); } } store/modules/CategoryStore.js import api from '~/api/CategoryApi' const state = () => ({ categories: [] }); const

how to get nested getters in vuex nuxt

女生的网名这么多〃 提交于 2020-08-09 12:03:47
问题 i have store/index.js like this new Vuex.Store({ modules: { nav: { namespaced: true, modules: { message: { namespaced: true, state: { count: 0, conversations: [], }, getters: { getCount: state => { return state.count; }, }, mutations: { updateCount(state) { state.count++; }, }, actions: {}, }, requests: { namespaced: true, state: { friends: [], }, getters: { getFriends: state => { return state.friends; }, }, mutations: { pushFriends(state, data) { state.friends.push(data); }, }, actions: {

how to get nested getters in vuex nuxt

↘锁芯ラ 提交于 2020-08-09 12:03:26
问题 i have store/index.js like this new Vuex.Store({ modules: { nav: { namespaced: true, modules: { message: { namespaced: true, state: { count: 0, conversations: [], }, getters: { getCount: state => { return state.count; }, }, mutations: { updateCount(state) { state.count++; }, }, actions: {}, }, requests: { namespaced: true, state: { friends: [], }, getters: { getFriends: state => { return state.friends; }, }, mutations: { pushFriends(state, data) { state.friends.push(data); }, }, actions: {

Can I use “this” in mapMutations spread inside Vue instance methods?

假装没事ソ 提交于 2020-04-10 07:27:09
问题 I want to set Vuex mutations as follows: export default { props: { store: String }, methods: { ...mapMutations({ changeModel: `${this.store}/changeModel` }) } } But I catch the error: Uncaught TypeError: Cannot read property 'store' of undefined How do I correctly use props inside the module mutation name? I want to map this.$store.commit('form1/changeModel') , where form1 is set from props . 回答1: Vuex helper mapMutations can be used with a function which works with this . There does not seem