export default {
data() {
return {
rules: {
skus: {
type: 'array',
required: true,
defaultField: {
type: 'object', required: true,
fields: {
name: { required: true, trigger: 'blur', message: 'SKU 名称必须填写' },
price: { type: 'number', required: true, trigger: 'blur', message: '价格必须填写' },
stock: { type: 'number', required: true, trigger: 'blur', message: '库存必须填写' },
}
}
}
}
}
},
methods: {
submitForm() {
this.$refs.postForm.validate((valid, obj) => {
if (valid) {
console.log('submit!!')
} else {
console.log('error submit!!')
return false
}
})
},
}
}
当调用 this.$refs.postForm.validate
错误的提示会遍历到所有的数组内
如下图所示:
1条答案
按热度按时间jc3wubiy1#
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.