Git Product home page Git Product logo

Comments (3)

michaelolof avatar michaelolof commented on June 10, 2024

Hello sorry for the late reply.

this.biggerNum is undefined because you're trying to access a getter from another getter.

Remember Vuex getters only have access to the state object.

from vuex-class-component.

rollinson9 avatar rollinson9 commented on June 10, 2024

Hi @michaelolof,

It's no problem, thank you for the reply!

I'm not sure if that's right? I've had no problem using the normal vuex way of access getters within getters. The first argument is state, but then the second argument is generally the getters object. Within namespaced modules, the 3rd and 4th argument are rootState and rootGetters

You should be able to see what I mean here:
https://vuex.vuejs.org/guide/getters.html#property-style-access

const store = new Vuex.Store({
  state: {
    todos: [
      { id: 1, text: '...', done: true },
      { id: 2, text: '...', done: false }
    ]
  },
  getters: {
    doneTodos: state => {
      return state.todos.filter(todo => todo.done)
    },
    doneTodosCount: (state, getters) => {
      return getters.doneTodos.length
    }
  }
})

https://vuex.vuejs.org/guide/modules.html#module-local-state

const moduleA = {
  // ...
  getters: {
    sumWithRootCount (state, getters, rootState, rootGetters) {
      return state.count + rootState.count
    }
  }
}

I hope this helps to explain what I mean, if this isn't a feature you're looking to implement then please let me know.

Thank you for you help!

from vuex-class-component.

DanCardin avatar DanCardin commented on June 10, 2024

We've also run into this problem. We make use of the 2nd getter param fairly extensively.

Any chance you'd consider (reopening this issue, and) fixing this or accepting a PR which adds support for it?

To a lesser extend we also use rootState and rootGetters, but we could probably live without that.

from vuex-class-component.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.