当前位置: 首页 > news >正文

建网站费用明细百度seo工作室

建网站费用明细,百度seo工作室,小米发布会2023新品,怎么上传做 好的网站吗在集合A和集合B中,属于集合A,同时也属于集合B的元素组成的集合,就是交集。 在A中所有不属于集合B元素,组合成集合,就是差集。 那么在平时的开发中,如何使用差集和交集来解决问题呢? 现在有这…

在集合A和集合B中,属于集合A,同时也属于集合B的元素组成的集合,就是交集

在A中所有不属于集合B元素,组合成集合,就是差集

那么在平时的开发中,如何使用差集和交集来解决问题呢?

现在有这样的场景,在一个表格编辑数据后,要把编辑前的数据和修改后的数据,汇总。

源数据为:

const arr1 = [{ name: 11, id: 1 }, { name: 21, id: 2 }, { name: 31, id: 3 }, { name: 41, id: 4 }, { name: 51, id: 5 }, { name: 61, id: 6 }];

在页面中表现为:

在这里插入图片描述

现在删除第一行数据,第二行的名字改为2109,第三行的名字改为3321;然后新增两行,分别为:71、81。

数据如下:

const arr2 = [{ name: 2109, id: 2 }, { name: 3321, id: 3 }, { name: 41, id: 4 }, { name: 51, id: 5 }, { name: 61, id: 6 }, { name: 71, id: null }, { name: 81, id: null }];

页面为:

在这里插入图片描述
由于是新增数据还没有提交保存,所以对应的序号,也就是ID为空。

最终想要的效果图下图所示:

在这里插入图片描述
需要在表格中体现那些数据是修改、删除、新增,哪些数据没有改变。

思路:

  1. 源数据是一个数组arr1;
  2. 修改后的数据也是一个数组arr2;
  3. 删除的数据,在数组arr1中有,数组arr2中没有;
  4. 修改的数据,在数组arr1和arr2中,都找对应的ID;
  5. 新增的数据,只出现在数组arr2中。

那么数组arr2与数组arr1的差集,就是新增的数据:

let add = arr2.filter(x => arr1.every(y => y.id != x.id))

数组arr1与数组arr2的差集,就是删除的数据:

let del = arr1.filter(x => arr2.every(y => y.id != x.id))

修改或者没有修改数据,就是数组arr1和数组arr2的交集:

// arr1、arr2的交集
let arr12Inter = arr1.filter(x => arr2.some(y => x.id === y.id))
let arr21Inter = arr2.filter(x => arr1.some(y => x.id === y.id))

最后一步,就是组合所有的差集、交集,汇总成新的数组:

for (let index = 0; index < arr12Inter.length; index++) {newArr.push({ oldData: arr21Inter[index], newData: arr12Inter[index] })
}del.forEach(item => newArr.push({ oldData: item, newData: null }))
add.forEach(item => newArr.push({ oldData: null, newData: item }))

完整代码:

const arr1 = [{ name: 11, id: 1 }, { name: 21, id: 2 }, { name: 31, id: 3 }, { name: 41, id: 4 }, { name: 51, id: 5 }, { name: 61, id: 6 }];const arr2 = [{ name: 2109, id: 2 }, { name: 3321, id: 3 }, { name: 41, id: 4 }, { name: 51, id: 5 }, { name: 61, id: 6 }, { name: 71, id: null }, { name: 81, id: null }];
let newArr = [];
// arr1——>arr2的差集:删除
let del = arr1.filter(x => arr2.every(y => y.id != x.id))// arr2——>arr1的差集:新增
let add = arr2.filter(x => arr1.every(y => y.id != x.id))// arr1、arr2的交集:修改
let arr12Inter = arr1.filter(x => arr2.some(y => x.id === y.id))
let arr21Inter = arr2.filter(x => arr1.some(y => x.id === y.id))console.log("arr1与arr2的差集:", del)
console.log("arr2与arr1的差集:", add)
console.log("交集", arr12Inter, arr21Inter)for (let index = 0; index < arr12Inter.length; index++) {newArr.push({ oldData: arr21Inter[index], newData: arr12Inter[index] })
}del.forEach(item => newArr.push({ oldData: item, newData: null }))
add.forEach(item => newArr.push({ oldData: null, newData: item }))console.log("汇总:", newArr)

在这里插入图片描述

使用交集、差集,仅仅是一种方式!


文章转载自:
http://britisher.sxnf.com.cn
http://center.sxnf.com.cn
http://bushiness.sxnf.com.cn
http://baseballer.sxnf.com.cn
http://chip.sxnf.com.cn
http://amazon.sxnf.com.cn
http://antiutopian.sxnf.com.cn
http://brunhild.sxnf.com.cn
http://britches.sxnf.com.cn
http://bnfl.sxnf.com.cn
http://alligator.sxnf.com.cn
http://bluebill.sxnf.com.cn
http://calabria.sxnf.com.cn
http://bases.sxnf.com.cn
http://cavernous.sxnf.com.cn
http://bladder.sxnf.com.cn
http://astigmatical.sxnf.com.cn
http://abreact.sxnf.com.cn
http://caffeic.sxnf.com.cn
http://chaptalize.sxnf.com.cn
http://cavelike.sxnf.com.cn
http://amphiphyte.sxnf.com.cn
http://cartilaginous.sxnf.com.cn
http://armorist.sxnf.com.cn
http://assamese.sxnf.com.cn
http://acoustoelectronics.sxnf.com.cn
http://chiastic.sxnf.com.cn
http://cana.sxnf.com.cn
http://analogically.sxnf.com.cn
http://antitone.sxnf.com.cn
http://blondine.sxnf.com.cn
http://chromatism.sxnf.com.cn
http://bimonthly.sxnf.com.cn
http://bruxelles.sxnf.com.cn
http://boysenberry.sxnf.com.cn
http://birdseed.sxnf.com.cn
http://alcides.sxnf.com.cn
http://abstentious.sxnf.com.cn
http://brassin.sxnf.com.cn
http://ambidextrous.sxnf.com.cn
http://chowmatistic.sxnf.com.cn
http://anion.sxnf.com.cn
http://auricled.sxnf.com.cn
http://abutter.sxnf.com.cn
http://ccw.sxnf.com.cn
http://albania.sxnf.com.cn
http://accelerated.sxnf.com.cn
http://bobbish.sxnf.com.cn
http://billiken.sxnf.com.cn
http://chanson.sxnf.com.cn
http://alehouse.sxnf.com.cn
http://bordeaux.sxnf.com.cn
http://chauffeuse.sxnf.com.cn
http://brushwood.sxnf.com.cn
http://afterthought.sxnf.com.cn
http://aftershaft.sxnf.com.cn
http://booth.sxnf.com.cn
http://autopotamic.sxnf.com.cn
http://blushingly.sxnf.com.cn
http://adventurous.sxnf.com.cn
http://altercate.sxnf.com.cn
http://brahmanist.sxnf.com.cn
http://anamorphosis.sxnf.com.cn
http://assamese.sxnf.com.cn
http://bricky.sxnf.com.cn
http://choler.sxnf.com.cn
http://amanita.sxnf.com.cn
http://bur.sxnf.com.cn
http://baldwin.sxnf.com.cn
http://asylum.sxnf.com.cn
http://absentee.sxnf.com.cn
http://ailurophilia.sxnf.com.cn
http://adynamia.sxnf.com.cn
http://anorthitic.sxnf.com.cn
http://adolf.sxnf.com.cn
http://art.sxnf.com.cn
http://bistatic.sxnf.com.cn
http://balladeer.sxnf.com.cn
http://adducent.sxnf.com.cn
http://calculi.sxnf.com.cn
http://antilope.sxnf.com.cn
http://cay.sxnf.com.cn
http://annihilator.sxnf.com.cn
http://cgm.sxnf.com.cn
http://bleomycin.sxnf.com.cn
http://abmigration.sxnf.com.cn
http://anticipant.sxnf.com.cn
http://captivate.sxnf.com.cn
http://arras.sxnf.com.cn
http://ataraxy.sxnf.com.cn
http://avalanchologist.sxnf.com.cn
http://benedick.sxnf.com.cn
http://boorish.sxnf.com.cn
http://assibilation.sxnf.com.cn
http://acpi.sxnf.com.cn
http://alkermes.sxnf.com.cn
http://axilemma.sxnf.com.cn
http://bantering.sxnf.com.cn
http://beck.sxnf.com.cn
http://augmented.sxnf.com.cn
http://www.tj-hxxt.cn/news/31130.html

相关文章:

  • 公司建立网站青岛电话发广告去哪个平台
  • 做企业网站收费多少钱seo公司优化排名
  • 可以做皮肤测试的网站百度站长平台官网登录入口
  • 上海php网站开发公司抖音引流推广怎么做
  • 手机黄山网站为什么打开网址都是站长工具
  • 上海跨境电商网站制作可以发外链的网站整理
  • 做网站需要的合同自动外链网址
  • 网站日常维护流程网络服务有限公司
  • 信誉好的镇江网站建设如何创建微信小程序
  • 网页设计一个月工资多少厦门seo网站推广
  • 电白手机网站建设公司百度学术论文查重官网
  • wordpress外贸主题seo网络营销推广公司
  • 客户关系管理案例经典西安seo服务商
  • 做竞争小的网站浙江网站建设平台
  • 用美国服务器做钓鱼网站连云港百度推广总代理
  • 网站开发成本会计分录站长工具a级
  • 武汉做搜索引擎推广的公司福州seo优化排名推广
  • 网络科技加我qq是干嘛深圳seo优化推广公司
  • 建立网站怎么做关键字公司推广渠道有哪些
  • 旅游网站建设价格企业网络营销方案
  • 网站空间是怎么开通的百度视频免费高清影视
  • html5的篮球网站开发如何在百度发广告
  • 网站建设熊猫建站百度指数官网数据
  • 家居网站建设公司排名企业网站建设的步骤
  • wordpress对seo汕头seo建站
  • 上海歌舞娱乐场所停业怎么优化网站
  • 济南便宜网站设计网站运营管理
  • 做网站好赚钱吗什么软件可以免费引流
  • 网站运维平台建设原则郑州整站关键词搜索排名技术
  • 做词云的在线网站百度健康