Skip to content

Instantly share code, notes, and snippets.

@chris001177
Created July 6, 2019 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris001177/56736d29e4a9625ad6409b32c3274ea9 to your computer and use it in GitHub Desktop.
Save chris001177/56736d29e4a9625ad6409b32c3274ea9 to your computer and use it in GitHub Desktop.
<template>
<div class="pleeease-click-me" @click="emitGlobalClickEvent()"></div>
</template>
<script>
// Import the EventBus we just created.
import { EventBus } from './event-bus.js';
export default {
data() {
return {
clickCount: 0
}
},
methods: {
emitGlobalClickEvent() {
this.clickCount++;
// Send the event on a channel (i-got-clicked) with a payload (the click count.)
EventBus.$emit('i-got-clicked', this.clickCount);
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment