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

    Different layout title on children routes

    Help
    5
    6
    1994
    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.
    • N
      Nico-L last edited by

      Heelo,

      First post here as I am learning vue + Quasar. So far I loved them both.

      SO I have a route with a layout a several children route. I’d like to have a different title in the layout depending on the children. How can I pass the title up to the layout?

      Thanks
      Nicolas

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

        Hi Nico, and welcome!

        This is mostly a vue issue, but quasar does come with some helpers for this.

        Here are a couple ways you could do this:

        1. Route Meta
          When declaring your routes in router.js, add a meta field
        {
          path: 'childroute',
          component: load('childcomponent'),
          meta: {
            title: 'Child component' 
          }
        }
        

        Then in your layout:

        {{$route.meta.title}}
        
        1. Emit an event to update title

        2. Vuex
          Use a centralized store to hold the title. Then access in layout like so:

        {{$store.getters.pagetitle()}}
        
        ? 1 Reply Last reply Reply Quote 1
        • N
          Nico-L last edited by

          Hi Benoit,

          Thanks for your answer. Sorry if it was rather a vue issue. As I am learning both at the same time, I have hard time to tell sometimes. I guess I’ll go along your first solution.

          Cheers

          1 Reply Last reply Reply Quote 1
          • ?
            A Former User @benoitranque last edited by

            This post is deleted!
            E 1 Reply Last reply Reply Quote 0
            • metalsadman
              metalsadman last edited by metalsadman

              use vuex like beonitranque’s last post. use a state for page title and set that using an action every time you change a route then use that state property in your q-toolbar-title {{ pageTitle }}. look into his example.

              1 Reply Last reply Reply Quote 0
              • E
                eCumbe @Guest last edited by

                @jaiken06 your children route should look’s like this :point_down

                 {
                        path: '/dividas', component: () => import('pages/dividas/Index.vue'),
                        meta: {
                          title: 'Dívidas'
                        }
                      },
                
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post