clock  Mon - Sun 8.00 AM - 8.00 PM
fb
instagram
play store
pinterest

How to Get the Search Parameters from the Current URL in Vue JS

writter  Hariom Prajapati
Date  02 Jan 2023
Language  Vue JS
How to Get the Search Parameters from the Current URL in Vue JS

How to Get the Search Parameters from the Current URL in Vue JS

In this tutorial we will learn how to get the search parameters from the current URL in Vue JS.

In Vue Js we will get the search query from the current URL using global route variable.

  var test = this.$route.query.test;
  console.log(test);  // hello

 

Lets see the below example in which we learn how to get the search parameters from the current URL in Vue JS.

 

Step 1- Create a view component.

 

Step 2- In the second step, simply paste the following code in your view component.

<template lang="">
    <div>
        <h1>User Information</h1>
        <h2>Name : {{$route.query.name}}  </h2>      
        <h2>Age : {{$route.query.age}}  </h2>      
        <h2>City : {{$route.query.city}}  </h2>      
    </div>
</template>

 

Step 3- Now, start the npm server

 

Output -