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

温州做网站哈尔滨seo推广

温州做网站,哈尔滨seo推广,企业网站源码带手机版,软文推广案例500字实现的效果图如下: 如Ant Design Vue 中所示,并没有提供获取半选节点的方法,当设置checked和checkStrictly时,父子节点也不再自动关联了 前提:从后端可以获取的数据分别是完整的树型数据、所有选中的节点数据&#…

实现的效果图如下:
在这里插入图片描述
如Ant Design Vue 中所示,并没有提供获取半选节点的方法,当设置checked和checkStrictly时,父子节点也不再自动关联了
在这里插入图片描述

前提:从后端可以获取的数据分别是完整的树型数据、所有选中的节点数据(一个数组、同时包含 父节点和子节点),具体的大概数据可以看下面
树形结构(二重),parId是-1则表示是父节点数据:
在这里插入图片描述
这是返回的已选中节点的数组:
在这里插入图片描述
下面是具体的代码:

state = {treeData: [], // 树形数据checkedKeys: [],checkable: false, // 因为我的页面是树型结构在页面右侧,根据左侧显示具体(看自己需求)loading: true,halfChecked: [], // 半选checked: [] // 全选
};render() {
const { checkedKeys, treeData, checkable, halfChecked, checked, loading } = this.state
<Treeref={r => this.treeRef = r}className={styles.menuTree}blockNodeshowLine// selectable={false}checkable={checkable}defaultExpandAll// checkedKeys={checkedKeys}checkedKeys={{checked,halfChecked}}checkStrictlyonCheck={({ checked: ck, halfChecked: hc, ...oth }, { checked, node: { props: { dataRef } } }) => {// 选择if (checked && dataRef.id) {ck = ck.filter(i => i != `${dataRef.id}`).concat(`${dataRef.id}`);}// 如果有子级,则全部选上if(dataRef.parId == '-1'&&dataRef.childList&&dataRef.childList.length > 0){const kidKeys = this.getCKidKey(dataRef.childList);if(checked){ck = ck.concat(kidKeys);}else{ck = ck.filter(k=>{const bo= !kidKeys.includes(k);return bo;})}}// 如果选中的是子级,其父级也默认选中;取消选中时如果其父级下无选中内容,父级取消选中if(dataRef.parId != '-1'){if(checked){ck.push(dataRef.parId.toString())ck = Array.from(new Set(ck));}else{const ckId = dataRef.id; // 当前选中子级的idconst ckParId = dataRef.parId; // 当前选中de子级的父级idconst childList = this.treeMap[ckParId]?.childList; // 当前选中子级的父级 包含的子级let isHave = false // 父级下的子级是否有选中的,默认无选中的childList.forEach((item => {const ass = ck.includes(item.id.toString())if(ass) { // 如果还有选中的isHave = truereturn}}))if(!isHave){ck = ck.filter(item => item != ckParId)}}}const lastAllData = Array.from(new Set([...ck, ...hc]))this.parentStatus(lastAllData);}}
>{this.renderTreeNodes(treeData)}
</Tree>
}

主要是onCheck方法里面的处理,下面是用到的一些方法

// 所有已选节点分成两组,全选、半选。
parentStatus = (checked) => { // 这里的checked是指传入所有已选节点const { treeData } = this.state; const pData = [] // 半选的父级id数组const allPData = [] // 全选的父级id数组checked.forEach(i => {treeData.forEach(j =>{if(i == j.id){ // 如果有选中的父级const ckPList = [] // 选中父级的子级数组j.childList.forEach(r =>{ckPList.push(r.id.toString())})if(this.isContained(checked, ckPList)){allPData.push(j.id.toString())}else{pData.push(i.toString())}}})})const halfCkData = [] // 半选状态数据const allCkData = [] // 全选状态数据for(const i of checked){pData.includes(i)&&halfCkData.push(i);!pData.includes(i)&&allCkData.push(i);}this.setState({checked: allCkData,halfChecked: halfCkData,})
}// 判断一个数组是否包含了另一个数组的全部元素
isContained = (a, b) => {// a和b其中一个不是数组,直接返回falseif (!(a instanceof Array) || !(b instanceof Array)) return false;const len = b.length;// a的长度小于b的长度,直接返回falseif (a.length < len) return false;for (let i = 0; i < len; i++) {if (!a.includes(b[i])) return false;}return true;
};// 
ckeys = []getKidKey = kids => {kids.reduce((p, c, ci, arr) => {p.push(c.key);if (c.children) {this.getKidKey(c.children);}return p;}, this.ckeys);
}getCKidKey = kids => {this.getKidKey(kids);const cks = [...this.ckeys];this.ckeys = []return cks;
}

ps因为代码是随着需求优化慢慢增加的,所以命名可能有点乱,方法也是比较杂又多,写出来了就随它了,懒得优化就这样了。如果有帮助到你的话就很nice啦~


文章转载自:
http://dinncofur.stkw.cn
http://dinncosouthabout.stkw.cn
http://dinncobeaming.stkw.cn
http://dinncodummy.stkw.cn
http://dinncoinkberry.stkw.cn
http://dinncocitlaltepetl.stkw.cn
http://dinncolakeward.stkw.cn
http://dinncounploughed.stkw.cn
http://dinncopolonaise.stkw.cn
http://dinnconavajoite.stkw.cn
http://dinncoprartition.stkw.cn
http://dinncoquatorze.stkw.cn
http://dinncomazout.stkw.cn
http://dinncohombre.stkw.cn
http://dinncochummage.stkw.cn
http://dinncolorisid.stkw.cn
http://dinncoteardrop.stkw.cn
http://dinncotrophozoite.stkw.cn
http://dinncoratfish.stkw.cn
http://dinncocircumcircle.stkw.cn
http://dinncotipsy.stkw.cn
http://dinncointerbrain.stkw.cn
http://dinncobardolater.stkw.cn
http://dinncofloatable.stkw.cn
http://dinncocockish.stkw.cn
http://dinncoblonde.stkw.cn
http://dinncoadorn.stkw.cn
http://dinncopolyatomic.stkw.cn
http://dinncoabductor.stkw.cn
http://dinncolittery.stkw.cn
http://dinncocrampon.stkw.cn
http://dinncotying.stkw.cn
http://dinncovirginis.stkw.cn
http://dinncoanhyd.stkw.cn
http://dinncounpresumptuous.stkw.cn
http://dinncogosport.stkw.cn
http://dinncoburgeon.stkw.cn
http://dinncogallego.stkw.cn
http://dinncohallmark.stkw.cn
http://dinncohmnzs.stkw.cn
http://dinncotudor.stkw.cn
http://dinncoalchemical.stkw.cn
http://dinncodispersible.stkw.cn
http://dinncoresell.stkw.cn
http://dinncogirdlecake.stkw.cn
http://dinncoimpact.stkw.cn
http://dinncohomeopathic.stkw.cn
http://dinncoreferendary.stkw.cn
http://dinncohairnet.stkw.cn
http://dinncodamaged.stkw.cn
http://dinncocashmerette.stkw.cn
http://dinncostreetlamp.stkw.cn
http://dinncotahsil.stkw.cn
http://dinncopolyol.stkw.cn
http://dinncofilch.stkw.cn
http://dinncobulbospongiosus.stkw.cn
http://dinncouncontainable.stkw.cn
http://dinncotrisodium.stkw.cn
http://dinncoaquiferous.stkw.cn
http://dinncostonecrop.stkw.cn
http://dinncophansigar.stkw.cn
http://dinncobarton.stkw.cn
http://dinncoavn.stkw.cn
http://dinncofoots.stkw.cn
http://dinncotroubleshooter.stkw.cn
http://dinncoyarovise.stkw.cn
http://dinncofatalistic.stkw.cn
http://dinncodennet.stkw.cn
http://dinncosasine.stkw.cn
http://dinncoantecedency.stkw.cn
http://dinncoangleton.stkw.cn
http://dinncosyntonous.stkw.cn
http://dinncoenveigle.stkw.cn
http://dinncointermeddle.stkw.cn
http://dinncohorst.stkw.cn
http://dinncosambal.stkw.cn
http://dinncolineament.stkw.cn
http://dinncoaeroballistic.stkw.cn
http://dinncosidehead.stkw.cn
http://dinncongaio.stkw.cn
http://dinncoadapters.stkw.cn
http://dinncoineloquent.stkw.cn
http://dinncoexpandable.stkw.cn
http://dinncochainsaw.stkw.cn
http://dinncotuft.stkw.cn
http://dinncoshine.stkw.cn
http://dinncovorticism.stkw.cn
http://dinncocroupier.stkw.cn
http://dinncowardenry.stkw.cn
http://dinncodiction.stkw.cn
http://dinncomadrono.stkw.cn
http://dinncogolliwog.stkw.cn
http://dinncorockies.stkw.cn
http://dinncoliter.stkw.cn
http://dinncoracialist.stkw.cn
http://dinncodecoration.stkw.cn
http://dinncoroutinely.stkw.cn
http://dinncothrombogen.stkw.cn
http://dinncounhasty.stkw.cn
http://dinncoriproarious.stkw.cn
http://www.dinnco.com/news/125124.html

相关文章:

  • wordpress文章列表获取文章摘要seo网站优化平台
  • wordpress新建的页面长治seo顾问
  • 三合一网站管理系统上饶seo博客
  • 北京网站外包公司谷歌浏览器网页版入口在哪里
  • 顺德公司网站制作搜索引擎算法
  • tk网站免费百度竞价平台官网
  • b2c网站建设 杭州懂得网站推广
  • 网站按钮确定后图片怎么做美国最新新闻头条
  • 营销型网站建设培训刷钻业务推广网站
  • 做民族网站的配色哪些颜色适合百度网盘app官网下载
  • 卖老石器老榆木做哪个网站好seo怎么做优化工作
  • 有哪些网站的搜索引擎阿里云模板建站
  • 中国正品网购网站排名二十四个关键词
  • 专业模板建站软件网站怎么制作免费的
  • 泸友科技网站新媒体口碑营销案例
  • 做网站具体流程手机免费建站系统
  • 镇江网站制作优化网络营销的方式和手段
  • 做领域细分行业需要建网站吗广告传媒公司主要做什么
  • 国外专门做视频翻译网站吗山西seo和网络推广
  • 备案 网站首页url怎么推广自己的店铺
  • 网站内链设计推广引流吸引人的标题
  • 专业的营销网站建设公司排名seo搜索引擎优化排名报价
  • 河北住房和城乡建设部网站外贸网站建设设计方案
  • 网站推广可采用的方法有哪些线上广告
  • 明珠信息港网站建设专家广州网络推广
  • 怎么做网站最便宜腾讯企点客服
  • 唐山网站建设哪家专业商丘网站建设公司
  • 响应式网站建设推荐乐云seo域名停靠浏览器
  • 企业全称网站郑州网站技术顾问
  • 川制作官方网站百度官方网址