How to call prop function from setup in vue 3

Viewed 10071

I have the next code:

HTML:

<p @click="changeForm">Iniciar sesion</p>

JS

export default {
   name: "Register",
   props: {
      changeForm: Function,
   },
   setup() {
      //How can i call props changeForm here???
   }
}

How can i call my props function from JS? The other way around is to trigger click on my p element, is that possible?

I am using vue 3. I have tested with this.changeForm and props.changeForm with no luck.

1 Answers

The setup function receives props as its first argument:

export default {
   name: "Register",
   props: {
     changeForm: Function,
   },
   setup(props) {            // receive `props` argument
     props.changeForm();     // use it to access `changeForm`
   }
}
Related