2👍
✅
You can wrap title and body in an object
addPost() {
const post = {
title: this.createTitle,
body: this.createBody
}
eventEmitter.$emit('postAdd', post)
}
and then listen as normal
created(){
eventEmitter.$on('postAdd', (post) => {
console.log(post)
// do whatever you want
})
}
1👍
I have not worked on vue js but agreed with @ittus answer. You can make an object consisting of your required data which you want to share across the component and pass it as an event data.
Source:stackexchange.com