How to dynamically add methods to the defineEmits() method
What problem does this feature solve?
Currently, there is a new requirement to encapsulate a dynamic button list that requires the method of dynamically configuring buttons. Previously, this was directly used in Vue2$ Emit() implementation, but in Vue 3.0, the declaration of defineEmits() is required now, but these methods need to be dynamically added. How do I implement it??
What does the proposed API look like?
暂无
you can define them as an empty array by default and add emits as props like:
const props = defineProps(['emits'])
defineEmits(props.emits ?? [])
you can define them as an empty array by default and add emits as props like:
const props = defineProps(['emits']) defineEmits(props.emits ?? [])
That won't work.