mirror of
https://github.com/element-plus/element-plus.git
synced 2025-08-14 18:11:48 +08:00
docs(components): check docs before stable (#5740)
This commit is contained in:
@ -35,11 +35,10 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive } from 'vue'
|
||||
// More info see https://github.com/element-plus/element-plus/blob/dev/docs/examples/form/utils.ts
|
||||
import { resetForm, submitForm } from './utils'
|
||||
import type { ElForm } from 'element-plus'
|
||||
|
||||
const ruleFormRef = ref<InstanceType<typeof ElForm>>()
|
||||
type FormInstance = InstanceType<typeof ElForm>
|
||||
const ruleFormRef = ref<FormInstance>()
|
||||
|
||||
const checkAge = (rule: any, value: any, callback: any) => {
|
||||
if (!value) {
|
||||
@ -90,4 +89,21 @@ const rules = reactive({
|
||||
checkPass: [{ validator: validatePass2, trigger: 'blur' }],
|
||||
age: [{ validator: checkAge, trigger: 'blur' }],
|
||||
})
|
||||
|
||||
const submitForm = (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return
|
||||
formEl.validate((valid) => {
|
||||
if (valid) {
|
||||
console.log('submit!')
|
||||
} else {
|
||||
console.log('error submit!')
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const resetForm = (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return
|
||||
formEl.resetFields()
|
||||
}
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user