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>
|
<script setup>
|
||||||
import { ref, watch } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
import cloneDeep from 'lodash/cloneDeep'
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
import { $i18nBundle } from '@/messages'
|
import { $i18nBundle } from '@/messages'
|
||||||
import { useVModel } from '@vueuse/core'
|
import { useVModel } from '@vueuse/core'
|
||||||
@@ -61,7 +61,11 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const initRules = () => {
|
//= ============form暴露============//
|
||||||
|
|
||||||
|
const form = ref()
|
||||||
|
|
||||||
|
const rules = computed(() => {
|
||||||
const ruleResult = {}
|
const ruleResult = {}
|
||||||
props.options.forEach(option => {
|
props.options.forEach(option => {
|
||||||
if (option.prop) {
|
if (option.prop) {
|
||||||
@@ -86,10 +90,9 @@ const initRules = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
form.value && form.value.clearValidate()
|
||||||
return ruleResult
|
return ruleResult
|
||||||
}
|
})
|
||||||
|
|
||||||
const rules = ref({})
|
|
||||||
|
|
||||||
const emit = defineEmits(['submitForm', 'update:model'])
|
const emit = defineEmits(['submitForm', 'update:model'])
|
||||||
|
|
||||||
@@ -103,17 +106,12 @@ const initFormModel = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
rules.value = initRules()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
initFormModel()
|
initFormModel()
|
||||||
|
|
||||||
watch(() => props.options, initFormModel, { deep: true })
|
watch(() => props.options, initFormModel, { deep: true })
|
||||||
|
|
||||||
//= ============form暴露============//
|
|
||||||
|
|
||||||
const form = ref()
|
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
form
|
form
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user