Answer the question
In order to leave comments, you need to log in
Vue Router how to pass variable?
Guys please help.
When you click on the link, another component opens, an id is passed to it through the route, a url of the form:
/adres/ID is formed,
everything is as it should be.
but it is required to pass one more parameter to this component, so that the component can write it to a variable, it does not work out in any way, there is not enough experience.
<router-link
tag="a"
class="button"
:to="{name: 'historyId', params: {id: historyItem.id, date: historyItem.date}, props: {id: historyItem.id, date: historyItem.date}}"
:key="historyItem.id"
>
<span class="button__icon">
<i class="fas fa-sync-alt"></i>
</span>
<span class="button__text">
Повторить
</span>
</router-link>
date: this.$router.currentRoute.params['date'],
Answer the question
In order to leave comments, you need to log in
and how to do it:
1. you need to set the permission to transfer props (props: true) in the route:
{
path: '/history/:id',
component: HistoryId,
name: 'historyId',
props: true
}
<router-link
tag="a"
class="button"
:to="{name: 'historyId', params: {id: historyItem.id, date: historyItem.date}}"
>
<script>
export default {
props: ['date'],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question