当前位置: 首页 > Web前端 > vue.js

v-for生成form表单验证报错this.$refs[formName].validateisnotafunction

时间:2023-03-31 20:53:08 vue.js

现象:使用V-for循环生成form-item,在进行表单验证时使用文档常规方法this。$refs[formName].validatebutthis.$refs[formName].validateisnotafunction问题:问题在于this.$refs[formName]是一个数组,循环中使用的表单验证是一样的,所以直接获取数组中的第一个this.$refs[formName][0].validate((valid)=>{}