Answer the question
In order to leave comments, you need to log in
How to pass parameter from router-link to single file component in vue.js?
There is a view link
<router-link :to="{ path: '/test', query: { parameter1: 'TEST'} }">Тест</router-link>
var router = new VueRouter({
routes: [
{ path: '/test', component: TestComponent, props: String }
]
})
<template>
<div>{{ parameter1 }}</div>
</template>
<script>
module.exports = {
props: ['parameter1'],
created: function(){
console.log(parameter1) //not defined
}
}
</script>
Answer the question
In order to leave comments, you need to log in
I did it through $route - just getting the parameters from the address bar. But I feel it's not the best solution.
With vue-router:
link:
/link?q=value
After declaring a component, address, etc.:
props: (route) => ({ query: route.query }) - pass all incoming
props: (route) => ({ query: route.query.q }) - if we expect a specific
example in off. documentation
https://router.vuejs.org/ru/guide/essentials/passi...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question