Navigation

    Quasar Framework

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. hitittome873
    H
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 3
    • Best 1
    • Groups 0

    hitittome873

    @hitittome873

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

    hitittome873 Follow

    Best posts made by hitittome873

    • RE: Reacting to router param change.

      I found out why it wasn’t working for me - when the Object.assign() call is made it only modifies the properties and not the entire object so the computed function is not actually triggered to rerun.

      This example works for my use case (hope it helps someone else 😄 )

      const routerState = Vue.observable<{route: Route}>({
        route: {
          fullPath: '',
          hash: '',
          matched: [],
          params: {},
          path: '',
          query: {},
        },
      });
      
      Router.afterEach((to) => {
        Object.assign(routerState, { route: to });
      });
      
      export const useRoute = () => computed(() => routerState.route);
      
      posted in Help
      H
      hitittome873

    Latest posts made by hitittome873

    • RE: Reacting to router param change.

      I found out why it wasn’t working for me - when the Object.assign() call is made it only modifies the properties and not the entire object so the computed function is not actually triggered to rerun.

      This example works for my use case (hope it helps someone else 😄 )

      const routerState = Vue.observable<{route: Route}>({
        route: {
          fullPath: '',
          hash: '',
          matched: [],
          params: {},
          path: '',
          query: {},
        },
      });
      
      Router.afterEach((to) => {
        Object.assign(routerState, { route: to });
      });
      
      export const useRoute = () => computed(() => routerState.route);
      
      posted in Help
      H
      hitittome873
    • RE: Reacting to router param change.

      This method doesn’t work if you are using typescript - you can’t pass a string as the first parameter to watch.

      I also tried the method where you create a hook like this and it’s not working either:

      // router.js
      const route = Vue.observable<Route>({
        fullPath: '',
        hash: '',
        matched: [],
        params: {},
        path: '',
        query: {},
      });
      
      Router.afterEach((to) => {
        Object.assign(route, to);
        console.log({route}) // this console log always executes
      });
      
      export const useRoute = () => computed(() => route);
      
      // in the component
      setup() {
        const route = useRoute();
        watch(route, (newVal) => console.log(newVal)); //this console log never executes
      }
      

      It’s weird because the console.log in the afterEach hook always runs but the one in the watcher never does…

      posted in Help
      H
      hitittome873
    • Vue router v3 compatible with quasar?

      I installed quasar and it used the v2 version of vue router which doesn’t have the hooks needed for the composition api. Is quasar compatible with vue router v3?

      posted in Help
      H
      hitittome873