Event.$on runs its callback function when the componenet is created, despite the $emitter has not emitted any event

Posted 2 years ago by Gatemark

Hello guys i add an event listener to my component at the created() function when i tried running the app, the event listener callback runs the `alert('am handling') in it without being called by the emitter my code

my navbar component

<template>
<li><a @click="Event.$emit('login')" class="uk-button uk-button-text" href="#">Login</a></li>
<li><a class="uk-button uk-button-text" href="#">Signup</a></li>
</template>

my login component

<template>
<div class="modal" :class="{'is-active':show_modal}">
  <div class="modal-background"></div>
</template>
<script>
created(){ Event.$on('login', alert('am handling')) // for debugging purposes
</script>

Globals window.Event = Vue(); when i run it, the alert shows, when i have not triggered the event............... Please whats wrong

Please sign in or create an account to participate in this conversation.