学无先后,达者为师

网站首页 编程语言 正文

uniapp 用forEach循环遍历数组

作者:maoge_666 更新时间: 2023-07-17 编程语言
<!-- 返回的数据:
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
	}
});

原文链接:https://blog.csdn.net/maoge_666/article/details/130151824

  • 上一篇:没有了
  • 下一篇:没有了
栏目分类
最近更新