Answer the question
In order to leave comments, you need to log in
How to pass a value to another component?
There is a Preloader component and a Header component.
When you click on the button in the Preloader component, it changes show to !show and this show should be passed to the Header component, which will only show at the moment v-if="!show".
thanks in advance
Answer the question
In order to leave comments, you need to log in
Something like this:
<template>
<preloader @show="show = $event"></preloader>
<header v-if="!show"></header>
</template>
export default {
data() {
return {
show: true
}
}
}
<template>
<button @click="handler"></button>
</template>
export default {
data() {
return {
show: false
}
},
methods: {
handler() {
this.show = !this.show
this.$emit('show', this.show)
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question