antdeign vue 动态添加输入框并带校验

<a-card style="margin-top: 24px;" :title="$t('activity.activityRule')" class="rulecard" v-if="activityData.activityType == 4">
					<a-radio-group v-model="ruleType" @change="changeRule">
						<a-radio :value="1">{{$t('activity.ladderReduce')}}</a-radio>
						<a-radio :value="2" style="margin-left: 20px">{{$t('activity.everyReduce')}}</a-radio>
					</a-radio-group>
					<a-form-model  :model="dynamicValidateForm" style="margin-top:15px" ref="dynamicValidateRef">
							<template v-if="ruleType == 2">
								<span  style="line-height:40px">{{$t('activity.everyfull')}}</span>
								<a-form-model-item  prop="domain2.value1"
								>
								<a-input-number :min="0" class="numberStyle" v-model="dynamicValidateForm.domain2.value1"/>
								</a-form-model-item>
								<span  style="line-height:40px">{{$t('activity.reduce')}}</span>
								<a-form-model-item  prop="domain2.value2" key="only"
								:rules="{
									required: true,
									message:$t('activity.notEmpty'),
									trigger: 'blur',
								}"
								>
								<a-input-number  class="numberStyle" v-model="dynamicValidateForm.domain2.value2"/>
								</a-form-model-item>
							</template>
							<template v-else>
								<template v-for="(domain, index) in dynamicValidateForm.domains" >
									<span :key="domain.index" style="line-height:40px">{{$t('activity.full')}}</span>
									<a-form-model-item :key="domain.index" :prop="'domains.' + index + '.value1'"
									:rules="{
										required: true,
										validator:checkRule1,
										trigger: 'blur',
									}"
									>
									<a-input-number :min="index == 0 ? 0 : 1" class="numberStyle" v-model="domain.value1"/>
									</a-form-model-item>
									<span :key="domain.index" style="line-height:40px">{{$t('activity.reduce')}}</span>
									<a-form-model-item :key="domain.index" :prop="'domains.' + index + '.value2'"
									:rules="{
										required: true,
										validator:checkRule2,
										trigger: 'blur',
									}"
									>
									<a-input-number class="numberStyle" v-model="domain.value2"/>
									</a-form-model-item>
									<a-icon :key="domain.index"
									v-if="dynamicValidateForm.domains.length > 1"
									type="minus-circle-o"
									class="dynamic-delete-button"
									@click="removeDomain(domain)"
									/>
									<br :key="domain.index" >
								</template>
								<a-button icon="plus" class="addBtd" style="width:380px" @click="addRule">{{$t('activity.newFullreduce')}}</a-button>
							</template>
					</a-form-model>	
					
			</a-card>

主要的坑就是 页面不显示rule校验结果,是因为要在a-form-model-item和span标签外面套个template。

相关推荐
她似晚风般温柔78912 分钟前
Uniapp + Vue3 + Vite +Uview + Pinia 分商家实现购物车功能(最新附源码保姆级)
开发语言·javascript·uni-app
Jiaberrr1 小时前
前端实战:使用JS和Canvas实现运算图形验证码(uniapp、微信小程序同样可用)
前端·javascript·vue.js·微信小程序·uni-app
everyStudy2 小时前
JS中判断字符串中是否包含指定字符
开发语言·前端·javascript
城南云小白2 小时前
web基础+http协议+httpd详细配置
前端·网络协议·http
前端小趴菜、2 小时前
Web Worker 简单使用
前端
web_learning_3212 小时前
信息收集常用指令
前端·搜索引擎
Ylucius2 小时前
动态语言? 静态语言? ------区别何在?java,js,c,c++,python分给是静态or动态语言?
java·c语言·javascript·c++·python·学习
tabzzz2 小时前
Webpack 概念速通:从入门到掌握构建工具的精髓
前端·webpack
LvManBa2 小时前
Vue学习记录之六(组件实战及BEM框架了解)
vue.js·学习·rust
200不是二百2 小时前
Vuex详解
前端·javascript·vue.js