Vuejs 2 Passing prop object to child component and retrieving
Simple as that:
Parent component:
<template>
<div>
<my-component :propObj="anObject"></my-component>
</div>
</template>
<script>
import ChildComponent from "ChildComponent.vue";
export default {
name: 'ParentComponent',
mounted() { },
props: {
anObject: Object
},
components: {
ChildComponent
},
}
</script>
<style scoped>
</style>
Child component:
export default {
props: {
// type, required and default are optional, you can reduce it to 'options: Object'
propObj: { type: Object, required: false, default: {"test": "wow"}},
}
}
This should work!
Take a look at props docs also:
https://v2.vuejs.org/v2/guide/components.html#Props
If you want to sent data from the child to the parent as was already pointed in the comments you have to use events or take a look at 'sync' feature which is available in 2.3 +
https://v2.vuejs.org/v2/guide/components.html#sync-Modifier