Ant Design Vue 表单验证踩坑

在最近采用Ant Design Vue的项目中,作者遇到了表单验证的困难,发现不能像使用elementUI或Iview那样直接用v-model进行验证。文章通过分享遇到的问题和贴出的代码示例,主要探讨了Ant Design Vue中如何实现必填项验证。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近一个项目用了 Ant Design Vue ,我也不知道为啥用这个。。。FORM表单验证踩地坑简直是让我哭哭哭

以前用elementUI,Iview,很顺手,v-model简直是标配
可是这个Ant Design Vue 在需要验证的时候 不能用 v-model,用v-decoration

贴代码 如下

<style lang="less">
@import 'sourceManage';
</style>
<template>
  <div ref="sourceManage">
    <a-row :gutter="24">
      <a-col :sm="12" :md="8" :xl="8">
        <h3>
          所属类目:
          <span>{
  {databaseType}}</span>
        </h3>
      </a-col>
      <a-col :sm="12" :md="3" :xl="3"  :offset="11">
        <a-button type="primary" icon="plus" @click="showSourseForm">添加源</a-button>
      </a-col>
    </a-row>
    <a-row :gutter="24" style="margin-top:30px;" v-if="databaseInformation.length">
      <a-col  :sm="12" :md="8" :xl="8" :style="{ marginBottom: '24px' }" v-for = "(databaseInfo,key) in databaseInformation" :key="key" >
        <a-card class="datatop">
          <a-icon type="check-circle" style="fontSize:16px;color:red" v-if="false"/>
          <a-icon type="close-circle" style="fontSize:16px;color:blue" />
          <span style="margin-left:100px;font-size:16px"><strong>information {
  {key+1}}</strong></span>
        </a-card>
        <a-card class="datacontent">
          <a-row>
            <a-col :span="4">  <a-icon type="database" theme="twoTone" style="fontSize:50px;color:blue;margin-top:10px" /></a-col>
            <a-col :span="10"> 
              <p><strong>库名称:</strong>{
  {databaseInfo.connectionName}}</p>
              <p><strong>IP:</strong>{
  {databaseInfo.databaseIp}}</p>
              <p><strong>描述: </strong>{
  {databaseInfo.databaseDescript || '无'}}</p>
            </a-col>
            <a-col :span="9" :offset="1">
             <p> <strong>类型:&
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值