Closed
Description
<template>
<view class="container">
<uni-forms ref="valiForm" :modelValue="formData" label-position="top" :rules="rules">
<uni-forms-item label="Email" name="email">
<uni-easyinput type="text" v-model="formData.email" placeholder="Enter Your Email" />
</uni-forms-item>
</uni-forms>
<button @click="onSubmit">Submit</button>
</view>
</template>
<script setup>
import { ref } from 'vue'
const valiForm = ref()
const formData = ref({})
const rules = ref({
email: {
rules: [
{
required: true,
errorMessage: 'Enter your email',
},
{
format: 'email',
errorMessage: 'Enter a right email',
},
{
minLength: 1,
maxLength: 10,
errorMessage: 'Email should be less than 10 characters.'
}
]
}
})
const onSubmit = () => {
valiForm.value.validate().then(res=>{
console.log('表单数据信息:', res);
}).catch(err =>{
console.log('表单错误信息:', err);
})
}
</script>
<style>
</style>
以上代码,只有required工作正常。如果输入不是email,错误提示还说提示required的错误提示,minLength和maxLength规则完全不起作用
Activity
GRCmade commentedon Mar 14, 2025
hello , 你是在哪个平台的执行的, 版本是多少 ?我尝试运行了一下代码,三种情况都是正常,这个是三种情况的运行截图:
GRCmade commentedon Mar 31, 2025
长时间未回复,关闭 issue,如果还存在这个问题,可以重新打开