vue 查询某个对象在对象列表的索引位置

vue 查询某个对象在对象列表的索引位置

let a = {
	id: 1,
	name: 'wjw'
}

let mList= [{
		id: 1,
		name: 'wjw'
	}, {
		id: 2,
		name: 'zqx'
	}]

let index = mList.findIndex(item => {
   return item.id === a.id;
});

// index 会返回0, 如果没有,返回 -1
posted @ 2021-06-09 15:54  我是+V  阅读(1115)  评论(0编辑  收藏  举报