对象数组根据某一项移除
2019-03-18 本文已影响0人
Sasoli
let urlDataSource=[
{ id: '1',name: 'aaa'},
{ id: '2',name: 'bbb'},
{ id: '3',name: 'ccc'},
];
//移除id为2的对象
let key = '2';
urlDataSource = urlDataSource.filter(i => !key.includes(i.id))
let urlDataSource=[
{ id: '1',name: 'aaa'},
{ id: '2',name: 'bbb'},
{ id: '3',name: 'ccc'},
];
//移除id为2的对象
let key = '2';
urlDataSource = urlDataSource.filter(i => !key.includes(i.id))