Author -  Sai gowtham

How to get the query parameters from a URL in Vue

In this tutorial, we are going to learn about how to access the query parameters data from a URL in Vue.js.

Consider, we have this following route with query parameters in our vue app.

localhost:3000/users?name="gowtham"

To get the query parameters from an above URL, we can use this.$route.query.paramName inside the vue components.

Example:

Users.vue
<template>
  <div>
    <h1>User</h1>
  </div>
</template>

<script>
export default {
  created() {
    console.log(this.$route.query.name);  }
};
</script>

Inside the vue component template, we can access it like this.

Users.vue
<template>
  <div>
    <h1>User: {{$route.query.name}}</h1>  </div>
</template>

<script>
export default {

};
</script>

If you are passing multiple query parameters to a URL using & operator.

localhost:3000/users?name=gowtham&id=1

You can access it like this.

Users.vue
<template>
  <div>
    <h1>Name: {{$route.query.name}}</h1>    <h1>Id: {{$route.query.id}}</h1>  </div>
</template>

Css Tutorials & Demos

How rotate an image continuously in CSS

In this demo, we are going to learn about how to rotate an image continuously using the css animations.

How to create a Instagram login Page

In this demo, i will show you how to create a instagram login page using html and css.

How to create a pulse animation in CSS

In this demo, i will show you how to create a pulse animation using css.

Creating a snowfall animation using css and JavaScript

In this demo, i will show you how to create a snow fall animation using css and JavaScript.

Top Udemy Courses

JavaScript - The Complete Guide 2023 (Beginner + Advanced)
JavaScript - The Complete Guide 2023 (Beginner + Advanced)
116,648 students enrolled
52 hours of video content
$14.99 FROM UDEMY
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
631,582 students enrolled
49 hours of video content
$24.99 FROM UDEMY
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
203,937 students enrolled
31.5 hours of video content
$14.99 FROM UDEMY