vuejs / babel-plugin-transform-vue-jsx

babel plugin for vue 2.0 jsx
1.85k stars 132 forks source link

[Question] How to use emits in component ? #204

Open ariran5 opened 3 years ago

ariran5 commented 3 years ago

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<{ ...