babel-plugin-transform-vue-jsx icon indicating copy to clipboard operation
babel-plugin-transform-vue-jsx copied to clipboard

[Question] How to use emits in component ?

Open ariran5 opened this issue 4 years ago • 0 comments

How to use components events with jsx ?

I use component with emits, and if i use this component in jsx then i can't add listener

// ModalMini.vue
...

  emits: ['change', 'leave'],
  setup(props, ctx){
    const {
      emit,
      slots,
    } = ctx
    emit('change', 123)
  ...
  }
...
// page.vue
...
<ModalMini
  class="ModalAnalitycs"
  onChange={changeShow}
>
...

onChange on ModalMini not work

TS says

Property 'onChange' does not exist on type 'IntrinsicAttributes & Partial<{ ...

ariran5 avatar Jun 29 '21 21:06 ariran5