如何从Vue 3中的设置调用prop函数

费尔南多·圣地亚哥(Fernando Santiago)

我有下一个代码:

HTML:

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

JS

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

如何从JS调用props函数?另一种方法是触发对我的p元素的点击,这可能吗?

我正在使用vue3。我已经用this.changeForm和props.changeForm进行了测试,但是没有运气。

ob

setup函数接收props其第一个参数作为:

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章