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. Zol
    Z
    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 1
    • Best 1
    • Groups 0

    Zol

    @Zol

    3
    Reputation
    89
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Zol Follow

    Best posts made by Zol

    • RE: [SOLVED] Access Vuex store in router.js

      @DarkLite1

      index.js
      
      // ...
      import makeRoutes from './routes'
      
      // ...
      export default function ({ store /* ,ssrContext */ }) {
        const routes = makeRoutes(store)
      
        return new VueRouter({
          scrollBehavior: () => ({ x: 0, y: 0 }),
          routes,
          // ...
        })
      }
      
      routes.js
      
      const makeRoutes = (store) => {
        const routes = [
          {
            path: '/',
            beforeEnter: (to, from, next) => {
              if (!store.state.auth.token) {
                next({ path: '/login' })
              } else {
                next()
              }
            },
            component: () => import('layouts/MainLayout.vue'),
            children: [
              { path: '', component: () => import('pages/Index.vue') },
              { path: 'about', component: () => import('pages/About.vue') }
            ]
          }
        ]
      
        // Always leave this as last one
        if (process.env.MODE !== 'ssr') {
          routes.push({
            path: '*',
            component: () => import('pages/Error404.vue')
          })
        }
      
        return routes
      }
      
      export default makeRoutes
      
      posted in Framework
      Z
      Zol

    Latest posts made by Zol

    • RE: [SOLVED] Access Vuex store in router.js

      @DarkLite1

      index.js
      
      // ...
      import makeRoutes from './routes'
      
      // ...
      export default function ({ store /* ,ssrContext */ }) {
        const routes = makeRoutes(store)
      
        return new VueRouter({
          scrollBehavior: () => ({ x: 0, y: 0 }),
          routes,
          // ...
        })
      }
      
      routes.js
      
      const makeRoutes = (store) => {
        const routes = [
          {
            path: '/',
            beforeEnter: (to, from, next) => {
              if (!store.state.auth.token) {
                next({ path: '/login' })
              } else {
                next()
              }
            },
            component: () => import('layouts/MainLayout.vue'),
            children: [
              { path: '', component: () => import('pages/Index.vue') },
              { path: 'about', component: () => import('pages/About.vue') }
            ]
          }
        ]
      
        // Always leave this as last one
        if (process.env.MODE !== 'ssr') {
          routes.push({
            path: '*',
            component: () => import('pages/Error404.vue')
          })
        }
      
        return routes
      }
      
      export default makeRoutes
      
      posted in Framework
      Z
      Zol