Answer the question
In order to leave comments, you need to log in
Can't figure out how to pass a parameter to vue.js from a component to a parent or another component?
I have a Navigation component.
How can I make sure that when I click on the button, in this Navigation component I have a parameter (a numeric value in data) passed to the parent app.vue component?
Answer the question
In order to leave comments, you need to log in
Raise the $emit event from child to parent components.
For example:
// дочерний компонент your-component
...
methods: {
doSomething() {
this.$emit('yourEvent', {
params: this.params,
})
}
}
// родительский компонент
<template>
<your-component :someProps="parent" @yourEvent="doSomething" />
</template>
...
methods: {
doSomething(data) {
// какой-то код
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question