0👍
So to update data of parent comp. from child component in Vue we can utilize event bus:
Parent:
<template>
Hi Blake...
<child-component @trigger="updateData()"></child-component>
</template>
<script>
export default {
mounted() {},
methods: {
updateData: function() {
// this will be triggered from child
}
}
}
</script>
Child ( child-component ):
<template>
<button @click="$emit('trigger')">Trigger Parent Function</button>
</template>
<script>
export default {
mounted() {}
}
</script>
Now this only triggers parent function but you can also send data with event that will be received by parent. This is just Vue without Vuex. If I’m wrong and you’re not looking for this maybe you want to use Vuex mapActions which can be used to import all Vuex actions you need in your component and use them as this.vuexAction
instead of this.$store.dispatch('vuexAction')
.
I hope I helped. Good luck.
- [Vuejs]-How to add attribute a value to my Combobox using vue Js?
- [Vuejs]-Laravel/Vue – Pass URL to Component
Source:stackexchange.com