<!-- 返回的数据:
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
	}
});
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐