Skip to content
Discussion options

You must be logged in to vote

覆蓋原本事件:

<script lang="ts" setup>
import type { ComponentProps } from 'vue-component-type-helpers';
import { XTextField } from '@x/ui'; 

type TextFieldProps = ComponentProps<typeof XTextField>;

interface Props extends /* @vue-ignore */ Omit<TextFieldProps, 'onClick'> { // Exclude a specific event from a component.
  // my props
}

defineOptions({
  inheritAttrs: false,
});

const props = defineProps<Props>();
const emit = defineEmits<(evt: 'click', payload: MouseEvent) => void>(); // Emit an event with the same name as the original event, but change the operation to your own.

function onMyClick() {
  // You can now modify the original event; it will still use the same name as the original.

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@Shyam-Chen
Comment options

@l246804
Comment options

@Shyam-Chen
Comment options

@Shyam-Chen
Comment options

Answer selected by l246804
@l246804
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants