8

How can I access $route.params property inside setup method in Vue.js? When I try to access it inside other method, or inside template everything works fine, but i cannot access it inside setup method.

Boussadjra Brahim
  • 82,684
  • 19
  • 144
  • 164

1 Answers1

16

You should use composable function useRoute to get the current route:

import { useRoute } from "vue-router";
    export default {
        setup() {
          const route =useRoute()
          //then use route.params 
           
        },
    };
Boussadjra Brahim
  • 82,684
  • 19
  • 144
  • 164