Skip to content

Behavior of custom events with same name, in parent and child compoents #8350

Discussion options

You must be logged in to vote

If you add the inheritAttrs: false configuration option to CustomComponent, you will find that only "from custom component" is printed. This is because components inherit attributes by default.

<CustomComponent @confirm="handleConfirm" />

=>

<button @click="$emit('confirm', 'from base component')" @confirm="$emit('confirm', 'from custom component')"  @confirm="handleConfirm">
    {{ text }}
  </button>
<template>
  <button @click="$emit('confirm', 'from base component')">
    {{ text }}
  </button>
</template>

<script>
import { defineComponent,getCurrentInstance } from "vue";

export default defineComponent({
  props: {
    text: { type: String },
  },
  setup(){
    const vm = getCurre…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by filiperaupp-egsys
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants