0👍
Your component needed emit a event with the parameter, then you get this value in parent component to process.
component.vue
<template>
<v-btn @click="onSendToParent()" />
</template>
<script>
export default {
data() {
return {
values: {
name: 'my name',
blabla: 'blablabla'
}
}
},
methods: {
onSendToParent() {
console.log(`✅ Emited sendToParent:`, this.values) // eslint-disable-line no-console
this.$emit('sendToParent', this.values)
}
}
}
</script>
parent.vue
<template>
<div>
{{ childData }}
<!-- @sendToParent is the name of your emiter, you can use change, update, and any thing you want. -->
<my-component @sendToParent="useChildData" />
</div>
</template>
<script>
import MyComponent from 'component'
export default {
components: {
MyComponent
},
data() {
return {
childData: false
}
},
methods: {
useChildData(event) {
console.log(`✅ get data Emited from childComponent:`, event) // eslint-disable-line no-console
this.childData = event
}
}
}
</script>
Source:stackexchange.com