I don't understand why my event is not listened correctly... Here my code, as you can see, i've created a component with an emit event based on the @click button event. Then, i've created my "v-on:my-event" to capture it..I don't understand why i don't see "yolo" in the console.
//Call of the component BaseButton
<base-button variant="projeo-btn-deeppurple" event-type="yololol">
<span class="mr-2">+</span> Ajouter un client
</base-button>
//Component BaseButton
<template>
<button
@click="sendEvent(eventType)"
:class="`${variant} md:text-lg sm:mb-0 mb-3 text-base font-medium pl-5 pr-8 py-2 rounded-xl`"
type="button"
>
<slot/>
</button>
</template>
<script>
export default {
props: {
eventType: {
type: String
},
variant: {
type: String,
validator: function (value) {
return (
[
"projeo-btn-deeppurple",
].indexOf(value) !== -1
);
}
}
},
methods: {
sendEvent (eventType) {
this.$emit(eventType)
}
}
}
</script>
//Component that listen on the event add-customer
<AddCustomerModal
v-on:add-customer="addCustomer"
v-if="addModalIsOpen"
:isEdition="isEdition"
:customerId="customer.id"
:modalTitle="modalTitle"
@close="addModalIsOpen = false"
ref="modalCustomer"
/>
//Script portion regarding the method addCustomer
<script>
methods: {
addCustomer () {
console.log("yolo")
}
}
Thanks for your future answer !