Open sunny-Fung opened 5 days ago
Bot detected the issue body's language is not English, translate it automatically.
Title: 🐛 [Bug]: When the drawer is closed, the pop-up form required prompt will not automatically close.
@sunny-Fung 表单的校验除了将 1、字段填对,2、主动关闭 这两种场景外,其他情况是不会主动关闭的。 如果需要在关闭抽屉时,消除表单校验提示,可以主动调用一下清除校验。
<template>
<div>
<tiny-button @click="openDrawer" type="primary"> 抽屉组件 </tiny-button>
<tiny-drawer title="标题" :visible="visible" @update:visible="visibleChange" @confirm="confirm">
<div class="demo-form">
<div class="title">标签文字对齐: <tiny-switch v-model="isLabelAlign"></tiny-switch></div>
<tiny-form
ref="ruleFormRef"
:model="createData"
label-position="left"
:label-align="isLabelAlign"
:hide-required-asterisk="false"
>
<tiny-form-item label="用户名" prop="username" required>
<tiny-input v-model="createData.username"></tiny-input>
</tiny-form-item>
<tiny-form-item label="密码" prop="password" required>
<tiny-input v-model="createData.password" type="password" show-password></tiny-input>
</tiny-form-item>
<tiny-form-item label="密钥" prop="password2">
<tiny-input v-model="createData.password2" type="password" show-password></tiny-input>
</tiny-form-item>
</tiny-form>
</div>
</tiny-drawer>
</div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import {TinyDrawer, TinyButton, TinyForm, TinyFormItem, TinyInput, TinySwitch } from '@opentiny/vue'
const ruleFormRef = ref()
const isLabelAlign = ref(true)
const createData = reactive({
username: '',
password: '',
password2: ''
})
const visible = ref(false)
const visibleChange = (val) => {
visible.value = val
if(!visible.value) {
ruleFormRef.value.clearValidate()
}
}
function openDrawer() {
visible.value = true
}
function confirm() {
visible.value = false
}
</script>
<style scoped>
.demo-form {
width: 380px;
}
.title {
margin-bottom: 20px;
font-size: 14px;
}
</style>
Version
3.19.0
Vue Version
3.4.27
Link to minimal reproduction