可以使用hasOwnProperty
1.打印已有对象
2.代码实例
const submitForm = (val: any, index: number) => {
const newObj = findProperty(options.formData, val.formItem.prop)
console.log(newObj, '结果')
}
const findProperty = (obj: any, property: any) => {
if (obj.hasOwnProperty(property)) {
return { [property]: obj[property] }
} else {
return null
}
}
val.formItem.prop为要查找的属性
options.formData是已知的对象也就是1.图