组件二封时原组件事件应该如何定义可以兼顾类型和便捷性? #14154
Answered
by
Shyam-Chen
l246804
asked this question in
Help/Questions
-
<script setup lang="ts">
import type { InputPropsPublic, InputEmits } from 'element-plus'
defineProps<{} & InputPropsPublic>()
// 使用 defineEmits 后,事件会跟 props 一样被组件自身消费掉,无法在 $attrs 里面获取,
// 这里除了 emits 一个一个重新抛出外还有别的比较便捷吗?
const emits = defineEmits<InputEmits>()
</script>
<template>
<ElInput v-bind="{ ...$props, ...$attrs }" />
</template> |
Beta Was this translation helpful? Give feedback.
Answered by
Shyam-Chen
Dec 8, 2025
Replies: 1 comment 6 replies
-
<script lang="ts" setup>
import type { InputHTMLAttributes } from 'vue';
interface Props extends /* @vue-ignore */ InputHTMLAttributes {
// ...
}
defineOptions({
inheritAttrs: false,
});
const props = defineProps<Props>();
</script> |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
覆蓋原本事件: