Skip to content
Advertisement

Tag: vuex

Display JSON file content in Vue

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 components

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 docs you’ve linked (emphasis mine): You can commit mutations in components with this.$store.commit(‘xxx’), or use the mapMutations helper which maps component methods to store.commit calls (requires root store injection)

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 what I’m doing wrong? I’m learning Vue and JS…. Answer There is two

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 updates 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 ‘@/store’ Here is the code to handle the

Advertisement