L
L
lookingfor22020-10-06 12:22:07
Vue.js
lookingfor2, 2020-10-06 12:22:07

Why doesn't the getter see it?

Issue:
[vuex] unknown getter: allTemplates index.js

file:

import template from './modules/template';
export default new Vuex.Store({
  modules: {
    template,
  },
)}


template.js file:

export default {
  actions: {},
  mutations: {},
  state: {
    templates: [],
  },
  getters: {
    allTemplates(state) {
      return state.templates;
    },
  },
};

structure
store
-modules/template.js
-index.js

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bqio, 2020-10-06
@bqio

import template from './modules/template';
export default new Vuex.Store(template)

But seriously, state should be a function.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question