【vue】项目中遇到的警告处理
1、Object.hasOwnProperty( v: PropertyKey): boolean
getTypeSelectionMenu().then(res => {
for (let item in res.data) {
//添加hasOwnProperty验证,作用是看看有没有这个属性
// if(res.data.hasOwnProperty(item)){
// this.parentList.push(res.data[item])
// }
this.parentList.push(res.data[item])
}
})
这里调用了接口,返回来了一个res对象,想要用res里的对象data里的一个属性,我知道里面有但是这样写不够严谨,所以会报一个警告:
Possible iteration over unexpected (custom / inherited) members, probably missing hasOwnProperty check
解决办法:上方注释

浙公网安备 33010602011771号