formSubmit(e){
var fieldsArr = [], flag = '', formData = e.detail.value || {}
Object.keys(formData).forEach(v=>{
v = v.replace(/(\d+)$/, '')
fieldsArr.indexOf(v) < 0 && fieldsArr.push(v)
})
for(var i in fieldsArr){
for(var n = 0;n<1;n++){
var k = fieldsArr[i]+n
if(!formData.hasOwnProperty(k)){
flag = k
break
}elseif(v = (formData[k]+'').trim(), v == ''){
flag = k
break
}
}
if(flag != '') break
}
flag != '' ? console.error(flag, '未填写或为空') : console.log('检查通过')
}
formSubmit(e){ var fieldsArr = [], flag = '', formData = e.detail.value || {} Object.keys(formData).forEach(v=>{ v = v.replace(/(\d+)$/, '') fieldsArr.indexOf(v) < 0 && fieldsArr.push(v) }) for(var i in fieldsArr){ for(var n = 0;n<1;n++){ var k = fieldsArr[i]+n if(!formData.hasOwnProperty(k)){ flag = k break }else if(v = (formData[k]+'').trim(), v == ''){ flag = k break } } if(flag != '') break } flag != '' ? console.error(flag, '未填写或为空') : console.log('检查通过') }
若认为该回答有用,给回答者点个[ 有用 ],让答案帮助更多的人
属性名自己拼