mirror of
https://github.com/fugary/simple-element-plus-template.git
synced 2025-11-12 14:27:49 +00:00
表单进入验证问题
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import { $i18nBundle } from '@/messages'
|
||||
import { useVModel } from '@vueuse/core'
|
||||
@@ -61,7 +61,11 @@ const props = defineProps({
|
||||
}
|
||||
})
|
||||
|
||||
const initRules = () => {
|
||||
//= ============form暴露============//
|
||||
|
||||
const form = ref()
|
||||
|
||||
const rules = computed(() => {
|
||||
const ruleResult = {}
|
||||
props.options.forEach(option => {
|
||||
if (option.prop) {
|
||||
@@ -86,10 +90,9 @@ const initRules = () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
form.value && form.value.clearValidate()
|
||||
return ruleResult
|
||||
}
|
||||
|
||||
const rules = ref({})
|
||||
})
|
||||
|
||||
const emit = defineEmits(['submitForm', 'update:model'])
|
||||
|
||||
@@ -103,17 +106,12 @@ const initFormModel = () => {
|
||||
}
|
||||
})
|
||||
}
|
||||
rules.value = initRules()
|
||||
}
|
||||
|
||||
initFormModel()
|
||||
|
||||
watch(() => props.options, initFormModel, { deep: true })
|
||||
|
||||
//= ============form暴露============//
|
||||
|
||||
const form = ref()
|
||||
|
||||
defineExpose({
|
||||
form
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user