Created
July 6, 2019 12:35
-
-
Save chris001177/56736d29e4a9625ad6409b32c3274ea9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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