uniapp 用forEach循环遍历数组
uniapp 用forEach循环遍历数组
·
<!-- 返回的数据:
res =[{
"parentId": null,
"orderNum": null,
"categoryId": 56,
"categoryName": "分类一",
"sort": 6
},
{
"parentId": 1,
"orderNum": null,
"categoryId": 57,
"categoryName": "分类二",
"sort": 6
}] -->
let parentIdList= res
parentIdList.forEach((item,index)=>{
if(item.parentId == null){
// 此处获得的id为56
this.categoryId = item.categoryId
}
});
更多推荐
已为社区贡献41条内容
所有评论(0)