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

    router-view and routing

    Framework
    5
    5
    4829
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      Credo last edited by

      Hi
      I’m trying to build my first website and I have chosen quasar.
      But I don’t seem to understand how quasar’s(or maybe vue’s) routing system works. It seems that I should add my routes to the routing.js file like below:

      routes: [
      { path: ‘/’, component: load(‘Index’) }, // Default
      { path: ‘/main’, component: load(‘mainLayout’) },
      { path: ‘*’, component: load(‘Error404’) } // Not found
      ]

      But this doesn’t work. localhost:8080/main, redirects to http://localhost:8080/main#/ which renders the default view. Actually even the 404 page doesn’t appear if I go to an undefined route and it still gives the default view.
      What should I do?
      Also, is it correct to say that <router-view></router-view> renders whatever template the routing system tells it to? Does it mean I don’t need to add my components manually to App.vue?
      Thanks

      1 Reply Last reply Reply Quote 0
      • benoitranque
        benoitranque last edited by benoitranque

        This is a vue-router issue, not a quasar issue. Read the vue-router docs.

        In vue-router the order you add routes in matters, a lot. The first match is what gets rendered.

        You do not need to add the slashes in your routes

        Yes, you do not need to add components to App.vue, only un your router file.

        1 Reply Last reply Reply Quote 0
        • s.molinari
          s.molinari last edited by s.molinari

          Try adding the “exact” prop in your links.

           <q-drawer-link icon="assignment_ind" to="/about" exact>
              About
           </q-drawer-link>
          

          Scott

          1 Reply Last reply Reply Quote 0
          • R
            rof20004 last edited by

            It is not a vue or quasar issue(based in your provided code), I think, you need to read the docs and understand how router works.

            1 Reply Last reply Reply Quote 0
            • rstoenescu
              rstoenescu Admin last edited by

              @Credo Read about configuring Vue Router in hash vs history mode. You are trying to access a path as if your Vue Router was configured to history mode ( http://localhost:8080/main), but the #/ at the end shows your Vue Router is in the default hash mode. http://router.vuejs.org/en/essentials/history-mode.html

              1 Reply Last reply Reply Quote 0
              • First post
                Last post