<template>
<div>
<el-form
ref="formlabelref"
:model="formlabel"
>
<el-form-item label="Name" prop="name">
<!-- xxx -->
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submit">Submit</el-button>
<el-button @click="reset">Reset</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script lang='ts'>
import { defineComponent, ref, unref } from 'vue'
export default defineComponent({
setup() {
let formlabelref = ref()
let formlabel = ref({
name: '',
})
const submit = () => {
const form = unref(formlabelref)
form.validate((valid)=>{
if(!valid){
//xxx
}
})
}
const reset = () => {
const form = unref(formlabelref)
form.resetFields()
}
return {
formlabel,
formlabelref,
submit,
reset
}
}
})
</script>
vue3+elemeng-plus表单resetFields的使用
最新推荐文章于 2024-07-23 13:31:48 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)