代码展示
this.obj = [
{ key: '', value: '' },
{ key: '1', value: '1' },
{ key: '3', value: '' },
{ key: '', value: '2' }
]
this.obj= this.obj.filter(x => {
// 过滤出来key不为''的对象 或者 value不为''的对象出来
return x.key !== '' || x.value !== ''
})
控制台结果:
[
{ key: '1', value: '1' },
{ key: '3', value: '' },
{ key: '', value: '2' }
]