I’ve json file with some data. I’ve to fetch this data and display them in the component. In my vuex store in actions I have: mutations: and state: And now how to get this todos in state and display them when Homepage is mounted? JSON file example: Answer Well you can use mapState in your componen…
Tag: vuex
How to combine each select tag’s data
I’m creating a sign-up page in vue3 now and trying to pass the value of birthDate. The date of birth consists of three select tags and each tag has a year, month, and day as an option. I want to combine the values of each select tags into birthDate. and need to deliver the value of the birthDate through…
What is the best way to use $state in Vue.js?
I used to do AngularJS and now I wanna try to work with Vue.js. But I have a simple question: what is the best way to use and access states? I saw so many solutions on Google but I can’t find which one is the best for a beginner. I used to use states like this : Can you give
Vue doesn’t see updates of my object getting from vuex
I have an object in vuex that im getting on the page by getters, but vue see only first update of object. I collect the object stepwise so first it’s empty then i have commit that updates vuex state (setUser) and vue showing this new info on the page. But then i use one more commit (addInfo) and it̵…
Does the store object in vuex fall through to leaf components?
Following the docs: https://vuex.vuejs.org/guide/mutations.html#committing-mutations-in-components and the video tutorial: https://scrimba.com/scrim/ckMZp4HN?pl=pnyzgAP it’s not clear (to me) whether store is visible in nested/child components present in the component that includes it. Answer From the d…
How do I make @click of a div that is receiving looped data of an API the div popups a window showing the rest of the keys in each object in the API
The div with {{user.name}} when clicked I want it to show the rest of the details in the Api like user.email, user.occupation, in a new window, Api data is coming from store. am still new to vuex. Answer Add click event listener to div with .native modifier if you are using Vue 2 or without if you are using V…
Currency Converter function in Vue3
I’m trying to implement a convert() function in a Vue3 project. I have a functions.js file to store some “global” basic functions I’m calling the function inside a component like this But it doesn’t work properly, I only get a pending Promise result… Can anybody tell me wha…
Best place to fetch data for authed users in Vue app?
Hi I’m fetching a arrays of posts from my express API in the Home.vue which is protected by route guards. fetchPosts action: In my action I commit a mutation which sets the posts object to res.data. I only want to fetchPosts when user logs in since I have a mutation which adds the post to the db and upd…
Getting mutation error in Nuxt JS while binding form with state
I am trying to bind my form’s fields with my vuex store in Nuxt JS. It works fine with normal text fields with get() set() in computed. But having trouble in customizing getting and setting manually. I am trying to push objects to an array in a specific format from my template to store and also keep the…
Conditional route for children routes in VueJS
I wonder how to redirect a children route conditionally. I’ve tried many ways but none of them works. I’m using a state from the store as the condition to redirect the children routes. I’ve exported my store from the file it is in and import it in the routes.js: import store from ‘@/st…