1

I am trying to list out the name for each budget using v-for. I use vuex getter to access the budgets associated with a user but it returns each object in the array. How do I access the name of each budget in the array?

Here I am attempting to list the budget names:

                    <v-list-item
                    v-for="(budget, key, index) in $store.getters.getBudgets"
                    :key="index"
                >

Here's the getter function in vuex.js

        getBudgets: state => {
       return state.user.budgets;
    }

Here are the results I am getting: Which is a list of objects like this, {id:29, name:Budget1...} {id:35, name:Budget2...}

1 Answer 1

3

You can loop over array objects and show the budget.name within the loop. Assuming that your budget ids are unique and not null, you don't need to use the index as key if that's the purpose.

<v-list-item v-for="budget in $store.getters.getBudgets" :key="budget.id">
   {{ budget.name }}
</v-list-item>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks I literally just figured it out!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.