router vue params code example

Example 1: query params vuejs

http://localhost:8000?name=John&[email protected]

 parameters = this.$route.query
 console.log(parameters)

 name = this.$route.query.name
 console.log(name)

Example 2: get params from route vuejs

const User = {
  template: '<div>User {{ $route.params.id }}</div>'
}

Example 3: vuejs router params

<router-link :to="{ name: 'movie', params: { id: item.id } }">{{ item.title }}</router-link>

Example 4: vue router url string

const resolved = this.$router.resolve({
  name: 'SomeRouteName',
  params: { id: item.id }
})
resolved.href // '/some-route-name/:id'

Tags:

Html Example