vue3 a-modal点击弹窗外让弹窗不关闭,且每次关闭置空输入框数据。
点击弹窗区域外不关闭弹窗::maskClosable=“false”
@cancel="handleClose"方法关闭modal置空数据
<a-modal v-model:visible="modalOpen" title="下发" width='50%'
:mask-closable="false" :destroy-on-close="true" @cancel="handleClose">
<a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="类别:" name="alarmTypeName">
<a-input :disabled="true" v-model:value="modalDetial.value.alarmTypeName" placeholder="请输入类别"
allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="时间:" name="alarmTime">
<a-input :disabled="true" v-model:value="modalDetial.value.alarmTime" placeholder="请输入时间"
allow-clear />
</a-form-item>
</a-col>
</a-row>
</a-form>
<template #footer>
<a-button style="margin-right: 8px" @click="handleClose">关闭</a-button>
<a-button type="primary" :loading="formLoading" @click="onSubmit">下发</a-button>
</template>
</a-modal>
...
...
...
//点击关闭按钮
const handleClose = () => {
formData.value = {}
modalOpen.value = false
}
//点击提交按钮
const onSubmit = () => {
//接口发送请求
warningInfoApi.addWork(params)
.then((res) => {
loadData()//刷新数据
handleClose()//调关闭modal方法置空input
})
})
}