You can emit an event that passes the data and listen for that ... but don't.
It's much better and easier to pass data down to the component.
And I’m trying to extract data from a child vue components within the parent component.
I’m using Laravel 5.4, btw.
I’ve broken down my code. What I basically want to do here is get the ‘title’ from the child component (Store.vue) and show it the parent component (List.vue).
List.vue
<template>
<div>
<h1>{{ title }}</h1>
<store></store>
</div>
</template>
<script>
import store from '../../components/List/Store.vue';
export default {
components: {
'store': store
},
created() {
this.title = store.title;
},
data () {
return {
title: ''
};
}
}
</script>
Store.vue
<template>
</template>
<script>
export default {
created() {
this.fetch();
// alert('Store.vue is loaded');
},
data () {
return {
title: ''
};
},
methods: {
fetch: function () {
this.title = 'my Title'
},
}
}
</script>
Later I want to get the title (and all other needed data) from an Ajax call in Store.vue.
I guess this must be simple for some of you but I’m a bit of a newbie and I’ve been at this for a long time now. I really hope someone is willing to help me out here.
Thanks!
You can emit an event that passes the data and listen for that ... but don't.
It's much better and easier to pass data down to the component.
Please or to participate in this conversation.