const getFilterValue = (array, value) => {
value = JSON.parse(JSON.stringify(value))
array.forEach(item => {
const newItem = Object.entries(item)[0]
if (value[newItem[0]] === newItem[1]) delete value[item.del]
})
return value
}
let formData = {
a: 0,
b: '123',
c: '456'
}
//条件,删除值
const remote = [{ a: 0, del: 'b' }]
getFilterValue(remote, formData)
如果想不受删除影响将getFilterValue改为
const getFilterValue = (array, value) => {
const newValue = JSON.parse(JSON.stringify(value))
array.forEach(item => {
const newItem = Object.entries(item)[0]
if (value[newItem[0]] === newItem[1]) delete newValue[item.del]
})
return newValue
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…