function hasEmptyField(obj) {
if (typeof obj === 'string') {
obj = JSON.parse(obj)
}
if (obj instanceof Object) {
for (var attr in obj) {
// 属性值是否含有'',null,undefined
if (obj.hasOwnProperty(attr) && (obj[attr] === '' || obj[attr] === null || obj[attr] === undefined)) {
return true
}
}
return false
}
}
const testObjA = {
a: '',
b: 123,
c: {a:111},
d: [1,12]
}
const testObjB = {
a: '555',
b: 123,
c: {a:111},
d: [1,12]
}
console.log('testObjA',hasEmptyField(testObjA))
console.log('testObjB',hasEmptyField(testObjB))