例如:
let listName1=ref([
{id:0, name:'小王'},
{id:1, name:'小张'},
{id:2, name:'小一'}])
let listName2=ref([
{id:0, name:'小马'},
{id:2, name:'小陈'},
{id:4, name:'小帅'}])
*///*****先定义一个变量存储 数组listName1中所有Id。
let newIdList=[]
listName1.value.forEach(item=>{
newIdList.push(item.id)})
//**********再判断数组listName2中是否存在和newIDList 数组相同的Id
listName2.value.forEach(item=>{
if(newIdList.indexOf(item.id)===-1){
listName1.value.push(item)
}})
得到新的数组:listName1