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

不懂外贸做外贸网站好做吗黄页网站推广效果

不懂外贸做外贸网站好做吗,黄页网站推广效果,使用门户网站网络推广方法,网站做SEO优化文章目录 前言1.原本代码2.新增逻辑3.优化逻辑 前言 原逻辑:后端data数据中返回数组,数组中有两个对象,一个是属性指标,一个是应用指标,根据这两个指标展示不同的多选框 1.原本代码 getIndicatorRange(indexReportLi…

文章目录

  • 前言
    • 1.原本代码
    • 2.新增逻辑
    • 3.优化逻辑


前言

原逻辑:后端data数据中返回数组,数组中有两个对象,一个是属性指标,一个是应用指标,根据这两个指标展示不同的多选框


1.原本代码

getIndicatorRange(indexReportList, target) {const indexList = []const indexObj = {}indexReportList.forEach(item => {item.showReportFieldList.forEach(fieldItem => {indexObj[fieldItem.showFieldTag] = {checked: target.includes(fieldItem.showFieldTag),disabled: item.name === '属性指标'}if (target.includes(fieldItem.showFieldTag)) {indexList.push({...fieldItem,// isAttri: item.name === '属性指标', // 判断是否是属性指标disabled: item.name === '属性指标'})}})})return {indexList,indexObj}},indexReportList.forEach(item => {const tarList = [...target] // 浅拷贝数组tarList.forEach(tarItem => {item.showReportFieldList.forEach(fieldItem => {indexObj[fieldItem.showFieldTag] = {checked: tarItem === fieldItem.showFieldTag,disabled: item.name === '属性指标'}if (tarItem === fieldItem.showFieldTag) {indexList.push({...fieldItem,// isAttri: item.name === '属性指标', // 判断是否是属性指标disabled: item.name === '属性指标'})}})})})

2.新增逻辑

这个选中的指标,可以进行拖拽,然后拖获取回显逻辑中,由于是遍历接口获取的源数组,导致拖拽保存后,重新进入页面,还是原本的拖拽顺序,也就是顺序没改。

3.优化逻辑

正常是在最外层使用遍历拖拽后的新数组,获取一个新的源数组进行渲染,但是这样加上本身的for循环,就有三层for循环了。优化后的代码如下:拷贝展示数据,遍历这个数据,将里面的是否存在,直接和item 的数据进行判断即可

在这里插入图片描述

优化后的代码

getIndicatorRange(indexReportList, target) {const indexList = []const indexObj = {}const targetMap = new Map();// 构建 targetMap,保持 target 的顺序target.forEach((tarItem, index) => {targetMap.set(tarItem, index);});indexReportList.forEach(item => {item.showReportFieldList.forEach(fieldItem => {const showFieldTag = fieldItem.showFieldTag;const isAttri = item.name === '属性指标';// 更新 indexObjif (!indexObj[showFieldTag]) {indexObj[showFieldTag] = {checked: false,disabled: isAttri};}// 如果 showFieldTag 在 target 中,更新 indexObj 并插入 indexListif (targetMap.has(showFieldTag)) {indexObj[showFieldTag].checked = true;// 插入 indexList,保持 target 的顺序indexList[targetMap.get(showFieldTag)] = {...fieldItem,disabled: isAttri};}})})return {indexList,indexObj}
},
http://www.tj-hxxt.cn/news/70921.html

相关文章:

  • 购物网站开发面试十种营销方法
  • 做视频怎样传到网站电商软文范例100字
  • b2c电商平台的特点淘宝优化关键词的步骤
  • php网站开发视频网站广州网站优化推广方案
  • 做公司网站的公司seo属于什么职位类型
  • 重庆用百度还是高德地图什么是seo优化推广
  • 免费版个人简历seo搜索引擎优化价格
  • 怎么看网站开发的好坏天津百度推广排名优化
  • 在外国租服务器做那种网站宁波seo优化公司
  • 做网站关键字微信营销推广方案
  • 51网站哪里去了seo点击软件
  • wordpress仿站教程网重庆seo排名外包
  • cmsapp模板网站艾滋病多久能查出来
  • 云阳网站建设电商运营推广怎么做
  • 织梦网站怎么做伪静态50篇经典软文100字
  • 金华做网站报价网络营销服务策略
  • 做音乐的网站设计竞价推广返点开户
  • 做网站有哪些费用怎么网站排名seo
  • 操作简单网站搭建费用移动营销
  • 广州个人网站搭建seo去哪里培训
  • 公司建设网站方案seo优化工作内容
  • 成都知名网站推广班级优化大师学生版
  • 怎么在网站做支付端口对接宁波seo怎么推广
  • webpack 网站开发百度推广教程视频教程
  • wordpress对接公众号开发者重庆快速排名优化
  • 网站建设有哪些特点优化网站收费标准
  • 宝鸡网站建设公司都有哪些seo排名专业公司
  • 做企业形象网站百度竞价登录
  • 南通网站开发公司手机app软件开发
  • 我赢网seo优化网站网站推广优化怎样