如何从 vue 3 中的设置调用 prop 函数
How to call prop function from setup in vue 3
我有下一个代码:
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 元素,这可能吗?
我正在使用 vue 3。我已经用 this.changeForm 和 props.changeForm 进行了测试,但没有成功。
setup
函数接收 props
作为其第一个参数:
export default {
name: "Register",
props: {
changeForm: Function,
},
setup(props) { // receive `props` argument
props.changeForm(); // use it to access `changeForm`
}
}
我有下一个代码:
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 元素,这可能吗?
我正在使用 vue 3。我已经用 this.changeForm 和 props.changeForm 进行了测试,但没有成功。
setup
函数接收 props
作为其第一个参数:
export default {
name: "Register",
props: {
changeForm: Function,
},
setup(props) { // receive `props` argument
props.changeForm(); // use it to access `changeForm`
}
}