Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
NuxtJS Event Bus Issue

I have created an eventBus in a plugins folder:

import Vue from 'vue'
      
const eventBus = {}
    
eventBus.install = function (Vue) {
    Vue.prototype.$bus = new Vue()
}
    
Vue.use(eventBus)

I have Updated my nuxt config file.

// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [
    '~/plugins/bus'
  ],

I have two card components on a homepage component. I want when I click the link on the card to take the user to another nuxt-linked page and set the data on that page to either true or false in the created() to conditionally render the data. I have set on the two different cards:

 <nuxt-link to="/tours-and-seminars" v-on:click="changeTourStatus">
      Click Here for More Information
    </nuxt-link>
  </div>
</template>
     <script>
export default {
  methods: {
    changeTourStatus: function () {
      this.$bus.$emit("changeTourStatus", true);
    },
  },
  name: "ToursCard",
};
</script>

The other card is the inverse of this setting it to false.

On my other page I have a simple v-if that if data: tours = true render one, if not render the other item on the page. I then have the below in the created() to change the "tours" data and then the page.

 created() {
this.$bus.$on("changeTourStatus", (data) => {
  console.log(data);
  this.tours = data;
});

}, };

I would hope loads with the the correct conditions to render either the one item or the other based on whatever the created() changes it to. But at the moment I am getting nothing show.

I am unsure if it is the bus I have added not working or if it is how I am sending the data. The console.log in the created() is returning nothing at the moment I can see in the dev tools.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!