vue.jsrouter

how can I use param value on the url by using vue router


I want to use param value of the url

but the params object is undefined in $router in my case

so how can I use params value

<script>
export default{

    data(){
        return{
            item:{},
            
        }
    },
    mounted(){
        console.log(this.$router);
    },
    



}
</script>

enter image description here

as you can see of the picture, there is no params object


Solution

  • You can get access to params like :

        mounted(){
            console.log(this.$router.currentRoute.params);
        },