Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

757
Visualizações
Vuex Uncaught Error: [vuex] getters should be function despite getter being a function

Encountering a problem with Vuex 4.0.2 where it throws an uncaught error indicating that a specific getter should be a function, even though it is indeed a function.

Error: Uncaught Error: [vuex] getters should be function but "getters.teamsWithPlayers" is [].

Vue 3.2.31

store/index.js

const getters = {
  teamsWithPlayers (state) {
    if (state.game.teams === undefined) {
      return state.game.teams
    }

    const teamsWithPlayersList = []

    state.game.teams.forEach(function (team) {
      const individualScores = []

      team.players = state.game.players.filter(player => team.name === player.team)
      team.players.forEach(function (player) {
        individualScores.push(player.score)
      })
      team.score = individualScores.reduce(function (a, b) {
        return a + b
      }, 0)

      teamsWithPlayersList.push(team)
    })

    return teamsWithPlayersList
  }
}

export default createStore({
  namespaced: true,
  state,
  mutations,
  actions,
  getters
})
~   
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Found the issue was with the creation of the Vue app in main.js. As I was upgrading an existing project from Vue 2 to Vue 3, there was a reference to the old Vuex object instantiation that I did not catch.

The incorrect main.js.

import { createApp } from 'vue'
import Vuex from 'vuex'

import App from './App.vue' 
import router from './router' 
import store from '@/store' 
    
import '@/assets/styles/reveal_theme.scss' 
    
const vuexStore = new Vuex.Store(store)

const app = createApp(App).use(router).use(vuexStore)
app.mount('#app')

This is fixed by removing the references to the old Vuex.Store.

Corrected main.js:

import { createApp } from 'vue'

import App from './App.vue' 
import router from './router' 
import store from '@/store' 
    
const app = createApp(App).use(router).use(store)
app.mount('#app')
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda