✨[完善]表单使用async-validator4.0.7实现校验功能
🐛[修复]下拉框点击自身不能隐藏和设置modelValue为空时不能置空下拉框
This commit is contained in:
@@ -41,10 +41,10 @@ const props = defineProps<{
|
||||
const openState = ref(false)
|
||||
|
||||
const open = function () {
|
||||
openState.value = true
|
||||
openState.value = !openState.value
|
||||
}
|
||||
|
||||
const selectItem = reactive({ label: '', value: props.modelValue })
|
||||
const selectItem = reactive({ label: null, value: props.modelValue })
|
||||
|
||||
provide('selectItem', selectItem)
|
||||
provide('openState', openState)
|
||||
@@ -56,4 +56,12 @@ watch(selectItem, function (item) {
|
||||
emit('change', item.value)
|
||||
emit('update:modelValue', item.value)
|
||||
})
|
||||
|
||||
watch(()=>props.modelValue, function (value) {
|
||||
if (!value) {
|
||||
selectItem.label = null;
|
||||
selectItem.value = '';
|
||||
emit('update:modelValue', null);
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user