[Vuejs]-VUE (Quasar) How can I access my localstorage data without the need for refresh

0👍

Try to access the Localstorage variable through vuex store.
i.e in store/store-curriculum.js

import { LocalStorage, SessionStorage } from 'quasar'
const state = {
   curriculumId: Localstorage.getItem('curriculumId') | null
}
const getters = {
   curriculumId: (state) => state.curriculumId,
}
const mutation = {}
const action = {}
export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
}

Then add the following in your Index.vue file

if (this.$store.getters.curriculum.curriculumId)) {
   console.log('mounted - success')
} else {
   console.log('mounted - failed')
}

Leave a comment