vue router go with params code example
Example 1: vue router push
this.$router.push("/path");
Example 2: url params vue
const routes=[
.
.
{path : '/page/:id?', name='page', component: Page},
.
.
name:'Page',
mounted(){
this.url_data=this.$route.params.id;
},
data(){
return{
url_data: null
};
}
<h2> {{url_data}}</h2>
Example 3: get params from route vuejs
const User = {
template: '<div>User {{ $route.params.id }}</div>'
}
Example 4: vue router url string
const resolved = this.$router.resolve({
name: 'SomeRouteName',
params: { id: item.id }
})
resolved.href
Example 5: programatic navigation vue router
router.push('home')
router.push({ path: 'home' })
router.push({ name: 'user', params: { userId: '123' } })
router.push({ path: 'register', query: { plan: 'private' } })