Answer the question
In order to leave comments, you need to log in
How to pass parameter from router to child component on page load?
Hello. There is a parent component, which hosts a child component, to which you need to pass a parameter from the current url (vue-router).
<template>
<favorite-button :userid="userid"/>
</template>
...
<script>
...
mounted() {
this.userid = this.$route.params.id;
}
...
</script>
Answer the question
In order to leave comments, you need to log in
You can't use this inside a component template this time. The second is that the id attribute is an html attribute and cannot be used as props, replace it with route-id for example.
In general, this transfer is meaningless, since you can get the parameter inside
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question