No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. danielsalles
    3. Best
    • Profile
    • Following 0
    • Followers 1
    • Topics 6
    • Posts 20
    • Best 2
    • Groups 0

    Best posts made by danielsalles

    • How can I access vue instance?

      I have had several problems with flow.
      I would like to access the localStorage (plugin) inside router / index.js for example.

      But the quasar load Router and then loads the Plugins, thus being Vue.localStorage be undefined :/.

      plugins/localStorage.js

      import VueLocalStorage from 'vue-localstorage'
      
      export default ({ app, router, Vue }) => {
      
        Vue.use(VueLocalStorage)
      
      }
      
      

      router/index.js

      import Vue from 'vue'
      import VueRouter from 'vue-router'
      
      import routes from './routes'
      
      Vue.use(VueRouter)
      
      const Router = new VueRouter({
        /*
         * NOTE! Change Vue Router mode from quasar.conf.js -> build -> vueRouterMode
         *
         * If you decide to go with "history" mode, please also set "build.publicPath"
         * to something other than an empty string.
         * Example: '/' instead of ''
         */
      
        // Leave as is and change from quasar.conf.js instead!
        mode: process.env.VUE_ROUTER_MODE,
        base: process.env.VUE_ROUTER_BASE,
        scrollBehavior: () => ({ y: 0 }),
        routes
      })
      
      Router.beforeEach((to, from, next) => {
        Vue.localStorage.set('teste', 'teste')
        next()
      })
      
      export default Router
      
      

      I need to access localStorage to check if a saved token exists, and if there is user information look for on the server.

      posted in Help
      danielsalles
      danielsalles
    • RE: How can I access vue instance?

      @rstoenescu Oh, my bad.

      I had added in components. Now I’ve got it, and it’s working.

      Many thanks for the support offered 🙂

      posted in Help
      danielsalles
      danielsalles