A
A
Alexander2019-01-15 13:53:00
Vue.js
Alexander, 2019-01-15 13:53:00

Passing input parameters to a component, how to implement?

Hello! There is a button on the component, when the button is clicked:

<v-btn :to="{ path: '/field_of_activity', props: { messageId: 1}}">+</v-btn>

another component opens and I pass a parameter there, but the parameter remained empty as it was. If I pass the parameter through the router.js file, then everything is transferred normally, but I need to pass the parameter in my own way, what could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2019-01-15
@Dgacarda

:to="{ path: '/field_of_activity', props: { messageId: 1}}"

You messed something up here. Parameters are certainly not passed through the props property - it is used in the description of routes.
If you want via path, then replace props with query (or add the necessary parameters directly to path), and in the description of the corresponding route, specify something like props: route => ({ ...route.query }).
Or you can make the route named, then change path to name with the appropriate value, and props to params.
If you want both options to be supported, then in the route description (besides adding the name) it will be something like this:
props: route => ({ ...route.query, ...route.params })

UPD. Here's a demo of what it might look like.

V
Vitaly Inchin ☢, 2019-01-15
@In4in

On the side of the component, the parameter is specified in props?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question