[Vuejs]-How to get data from a nested component

0👍

Like the article I mentioned in the comment, you can make a js file called event-bus.js, include code below.

// event-bus.js
import Vue from 'vue';
var EventBus = new Vue();
export default EventBus;

After that, import it both in QuestionOption.vue and Main.vue like this

import bus from './event-bus';

Then try it again. The reason why your code didn’t work is because you generated two Vue instances, they’ve got no relationship with each other, so no communication would happen.

Leave a comment