二维数组循环验证
<template>
<a-form ref="formRef" :model="formData">
<a-card :border="false" v-for="(item,index) in formData.tableData" :key="index">
<a-table :columns="columns" :data="item.list">
<template #mon="{ rowIndex }">
<a-form-item :field="`tableData.${index}.list.${rowIndex}.money`" :rules="[{required:true,message:'金额不能为空'}]">
<a-input-number v-model="formData.tableData[index].list[rowIndex].money" placeholder="请输入金额" />
</a-form-item>
</template>
</a-table>
</a-card>
</a-form>
</template>
<script setup lang='ts'>
import { reactive, ref } from 'vue'
const formRef = ref<any>()
const columns = ref<any>([
{
title:'姓名',
dataIndex:'Name',
},
{
title:'年龄',
dataIndex:'age',
},
{
title:'金钱',
dataIndex:'money',
slotName:'mon'
},
])
const formData = ref<any>({
tableData:[{
list:[
{
Name:'李逍遥',
age:18,
money:0
}
]
}]
})
</script>
<style lang='less'>
</style>