eventbus listen to $on can't be executed vue js

551 Views Asked by At

I am trying to use eventbus to send and get data from different components.I have created a global variable eventbus and in each component when i want to send data to a specific component I write this

eventBus.$emit('dis',this.displaytype);

and in this specific component I wrote:

eventBus.$on('dis', function (snippet) {
    this.displaydis = snippet
    console.log('display: ', this.displaydis)
  }.bind(this));

I have written this in created hook but this code is not executing.Can any one help me ?

0

There are 0 best solutions below