vue重置表单方法
vue重置表单方法步骤1.为表单添加ref引用,拿到表单的实例对象,ref里面的值loginFormRef就是表单的实例对象。<el-formlabel-width="0px"class="login_form"ref="loginFormRef">2.为button按钮添加click事件,在重置事件中,通过this访问到$refs,再拿到loginFormRef实例对象,最后再调用r
·
vue重置表单方法
步骤
1.为表单添加ref引用,拿到表单的实例对象,ref里面的值loginFormRef就是表单的实例对象。
<el-form
label-width="0px"
class="login_form"
ref="loginFormRef"
>
2.为button按钮添加click事件,在重置事件中,通过this访问到$refs,再拿到loginFormRef实例对象,最后再调用resetFields方法实现重置。
methods: {
// 点击重置按钮,重置表单事件
resetLoginForm: function() {
// console.log(this) this指向$refs的是通过ref获得的实例对象loginFormRef
this.$refs.loginFormRef.resetFields()
}
}
更多推荐
已为社区贡献1条内容
所有评论(0)