Skip to content

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

@ariran5

Description

@ariran5

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions