河南信阳网站建设公司电话做app和网站哪个

news/2025/9/23 7:51:14/文章来源:
河南信阳网站建设公司电话,做app和网站哪个,wordpress瀑布流主题,甘肃省建设厅招标办网站最近在react项目中需要一个树状组件#xff0c;但是又不想因为这个去引入一套UI组件#xff0c;故自己封装了一个基于react的树状组件#xff0c; 个人认为比较难得部分在于数据的处理#xff0c;话不多说直接上代码#xff1a; 下面是tree.js import React, {Component} …最近在react项目中需要一个树状组件但是又不想因为这个去引入一套UI组件故自己封装了一个基于react的树状组件 个人认为比较难得部分在于数据的处理话不多说直接上代码 下面是tree.js import React, {Component} from react; import ./tree.css; import Stack from ../utils/util;class Tree extends Component {constructor(props) {super(props)this.state {treeData: {},treeArray: [],treeObj: {},type: tree,parentId: pid,id: id,value: value,label: label,children: children,checkBox: false}this.checkMap {2: checked,1: partChecked,0: }}componentWillMount() {if (this.props.config.type.toLowerCase() tree) {this.setState({treeData: this.props.treeData,...this.props.config})} else {this.setState({treeArray: this.props.treeData,...this.props.config})}}componentDidMount() {if (this.state.type.toLowerCase() ! tree) {this.factoryArrayData()} else {this.factoryTreeData()}}componentDidUpdate() {}componentWillUnmount() {}factoryArrayData() {let data this.state.treeArray, obj {}, rootId null;data.map((v, i) {if (v[this.state.parentId] || v[this.state.parentId] 0) {if (obj[v[this.state.parentId]]) {if (obj[v[this.state.parentId]].children) {obj[v[this.state.parentId]].children.push(v)} else {obj[v[this.state.parentId]].children [v]}} else {obj[v[this.state.parentId]] {children: [v]}}} else {rootId v[this.state.id]}if (obj[v[this.state.id]]) {v.children obj[v[this.state.id]].children}obj[v[this.state.id]] v})this.setState({treeData: obj[rootId],treeObj: obj})}factoryTreeData() {let data this.state.treeDatalet stack new Stack();let obj {};stack.push(data);while (stack.top) {let node stack.pop();for (let i in node.children) {stack.push(node.children[i])}obj[node[this.state.id]] node}this.setState({treeObj: obj})}openNode (e, data) {if (e.stopPropagation) {e.stopPropagation();} else {window.event.cancelBubble true;}data.open !data.openthis.forceUpdate()}selectNode (e, data) {if (e.stopPropagation) {e.stopPropagation();} else {window.event.cancelBubble true;}this.setState({selectVal: data[this.state.value]}, () {if (this.props.nodeClick) {this.props.nodeClick(data[this.state.value])}})}selectCheckBox (e, data) {if (e.stopPropagation) {e.stopPropagation();} else {window.event.cancelBubble true;}let check data.checkedif (data.children data.children.length) {let stack new Stack();stack.push(data);while(stack.top) {let node stack.pop()for (let i in node.children) {stack.push(node.children[i])}if (check 2) {node.checked 0;} else {node.checked 2}}} else {if (check 2) {data.checked 0;} else {data.checked 2}}if (data[this.state.parentId] || data[this.state.parentId] 0) {this.updateParentNode(data)} else {this.forceUpdate()if (this.props.selectChange) {this.getCheckedItems()}}}updateParentNode (data) {let par this.state.treeObj[data[this.state.parentId]], checkLen 0, partChecked false;for (let i in par.children) {if (par.children[i].checked 2) {checkLen;} else if (par.children[i].checked 1) {partChecked true;break;}}if (checkLen par.children.length) {par.checked 2} else if (partChecked || (checkLen par.children.length checkLen 0)) {par.checked 1;} else {par.checked 0;}if (this.state.treeObj[par[this.state.parentId]] || this.state.treeObj[par[this.state.parentId]] 0) {this.updateParentNode(par)} else {this.forceUpdate()if (this.props.selectChange) {this.getCheckedItems()}}}getCheckedItems() {let stack new Stack ();let checkedArr [];stack.push(this.state.treeData);while (stack.top) {let node stack.pop();for (let i in node.children) {stack.push(node.children[i])}if (node.checked 2) {checkedArr.push(node[this.state.value])}}this.props.selectChange(checkedArr)}renderTreeParent() {let data this.state.treeDatareturn (div className{parentNode childNode ${data.open?open:close} ${data.children data.children.length?:noChildren}}span onClick{(e) this.openNode(e, data)} classNameopenNode/span{this.state.checkBox?div className{checkBox ${this.checkMap[data.checked]}} onClick{(e) this.selectCheckBox(e, data)}/div:div classNamefileBoximg src./images/file-icon.png alt//div}div className{nodeName ${this.state.selectVal data[this.state.value]?active:}} onClick{(e) this.selectNode(e, data)}{data[this.state.label]}/div{this.state.treeData.children ?div classNamechildList{this.renderTreeNode(data)}/div : null}/div)}renderTreeNode(data) {return data.children.map((val, ind) {return (div key{ind} className{childNode ${val.open?open:close} ${val.children val.children.length?:noChildren}}span onClick{(e) this.openNode(e, val)} classNameopenNode/span{this.state.checkBox?div className{checkBox ${this.checkMap[val.checked]}} onClick{(e) this.selectCheckBox(e, val)}/div:div classNamefileBoximg src./images/file-icon.png alt//div}{ind data.children.length - 1?span classNamelastNode/span:null}div className{nodeName ${this.state.selectVal val[this.state.value]?active:}} onClick{(e) this.selectNode(e, val)}{val[this.state.label]}/div{val.children ?div classNamechildList{this.renderTreeNode(val)}/div : null}/div)})}render() {return (div classNametree{this.renderTreeParent()}/div)} }export default Tree 下面是tree.css .tree {text-align: left; } .tree .childNode {padding-left: 20px;position: relative;background-color: #ffffff;z-index: 1; } .tree .childNode .checkBox {position: absolute;width: 16px;left: 20px;top: 0;z-index: 2;margin: 7px 10px 0;height: 16px;box-sizing: border-box;border: 1px solid #d2d2d2;vertical-align: text-bottom;font-size: 0;border-radius: 2px;cursor: pointer; } .tree .childNode .checkBox:hover {cursor: pointer;border-color: #5bb976; } .tree .childNode .checkBox.checked {border: 0;background: url(../images/icon-check-green.png) no-repeat center center;background-size: 100% 100%;background: none\9;filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src./images/icon-check-green.png, sizingMethodscale) \9; } .tree .childNode .checkBox.partChecked {border: 0;background: url(../images/part-checked.png) no-repeat center center;background-size: 100% 100%;background: none\9;filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src./images/part-checked.png, sizingMethodscale) \9; } .tree .childNode .nodeName {padding-left: 36px;font-size: 14px;color: #333333;white-space: nowrap;overflow: hidden;line-height: 30px;height: 30px;text-overflow: ellipsis;position: relative;z-index: 1;display: inline-block;padding-right: 10px; } .tree .childNode .nodeName.active {background-color: #DEF1FF; } .tree .childNode .nodeName:hover {text-decoration: underline;cursor: pointer; } .tree .childNode.open .openNode {background: url(../images/department-close.png) no-repeat center center;background-size: 100% 100%;background: none\9;filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src./images/department-close.png, sizingMethodscale) \9; } .tree .childNode.open .childList {display: block; } .tree .childNode.close .openNode {background: url(../images/depart-open.png) no-repeat center center;background-size: 100% 100%;background: none\9;filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src./images/depart-open.png, sizingMethodscale) \9; } .tree .childNode.close .childList {display: none; } .tree .childNode .fileBox {position: absolute;width: 16px;left: 20px;top: 0;margin: 5px 10px 0;z-index: 2; } .tree .childNode .fileBox:hover {cursor: pointer; } .tree .childNode .fileBox img {width: 16px; } .tree .childNode:before {position: absolute;left: -13px;top: 15px;width: 20px;height: 100%;border-top: 1px solid #CFCFCF;border-right: 1px solid #CFCFCF;content: ;z-index: 1; } .tree .childNode:after {position: absolute;bottom: -12px;left: 7px;width: 1px;height: 30px;z-index: 3;background-color: #ffffff;content: ; } .tree .childNode.parentNode:before {border-top: none; } .tree .childNode .openNode {position: absolute;z-index: 5;left: 0;top: 8px;width: 14px;height: 14px; } .tree .childNode .openNode:hover {cursor: pointer; } .tree .childNode.noChildren .openNode {width: 10px;height: 10px;top: 10px;left: 7px;background: url(../images/no-child.png) no-repeat center center;background-size: 100% 100%;background: none\9;filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src./images/no-child.png, sizingMethodscale) \9; } .tree .childNode.noChildren .openNode:hover {cursor: default; } .tree .childNode .lastNode {position: absolute;bottom: -15px;left: -13px;width: 1px;height: 100%;z-index: 4;background-color: #ffffff; } utils里面是封装了一个stack栈关于js栈的使用请移步js遍历树状数据文章。 github项目地址转载于:https://www.cnblogs.com/marvey/p/10796175.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/911824.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

网站后台服务器内部错误开网站做商城怎么样

今日简单分享 container 组件的源码实现,从以下两个方面来讲解: 1、container 组件的页面结构 2、container 组件的属性 一、container 组件的页面结构 二、container 组件的属性 1、container 部分的 direction 属性,子元素的排列方向&am…

宠物网站页面设计ps怎么创建一个网页

【Ascend C】昇腾Ascend C算子开发入门课程,新手零基础入门 摘要:本课程是Ascend C算子开发的初级教程,通过课程讲解及样例实操,帮助你学习如何使用Ascend C开发矢量算子。 1、了解并行计算架构、并行计算方法等基本概念 2、理解…

论学院网站建设项目的进度管理天津百度搜索网站排名

我们在本地电脑使用小皮面板phpstudy安装phpMyAdmin4.8.5成功后,但是点击【管理】功能打开时却出现如下错误: Fatal error: Unparenthesized a ? b : c ? d : e is not supported. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e) in D:\…

网站开发中界面做网站哪家公司好

Web 是一种分布式应用架构,旨在共享分布在网络上的各个Web服务器中的所有互相链接的信息。 Web 采用客户/服务器通信模式,客户与服务器之间用HTTP协议通信。 Web 使用超级文本技术(HTML)来链接网络上的信息。信息存放在服务器端&a…

硅橡胶东莞网站建设爱客源

💂 个人网站:【 海拥】【神级代码资源网站】【办公神器】🤟 基于Web端打造的:👉轻量化工具创作平台💅 想寻找共同学习交流的小伙伴,请点击【全栈技术交流群】 在Java工程师的职业生涯中,深入理解…

医疗手机网站模板专门做电视剧截图的网站

文章目录 前言一、pandas是什么?二、使用步骤 1.引入库2.读入数据总结 前文中提到万能密钥的工作原理,然而万能密钥仅在源代码中没有代码审计,此时才被称之为万能密钥,而代码中有代码审计时需要分以下几种情况讨论 一.uagent注入 …

成武网站建设重庆市网络公司

【问题描述】[中等] 【解答思路】 1. 暴力 直接复制 将链表从头节点一个一个复制下去, 在根据记录的总长度num,遍历原来的每个节点的random到尾节点个数count,然后顺序遍历找到新链表的该指针在num-count上 。 时间复杂度:O(N^2…

松江 网站建设公司网页设计图片相对路径

安装 先从 官方网站 下载安装包,有时 node 版本太新会导致失败,详见下方的常见问题第2点 cd /home // 创建目录,将下载好的 node 安装包上传到此目录 mkdir Download mkdir /usr/local/lib/node解压 // 解压,前面是文件当前路径…

网站建设哪里好薇浙江省建设培训中心网

第一步:得到Pid 如果我们不知道TAG的情况下,先得到进程的PID adb shell ps | grep call 会显示出进程关于call的出来 比如得到pid 是1123 第二步:过滤Pid adb logcat | grep 1123 就可以看到过滤的日志了 常见的命令 杀死进程 adb shell kill pid adb shell am force-s…

ps做网站头部的图网站建设站长

Guava是一个开放源代码库,其中包含许多Java类,由Google编写。 它是杂项实用程序函数和类的潜在有用来源,我敢肯定,许多开发人员以前已经写过自己,或者只是想要并且从来没有时间编写它们。 这是使用它的5个充分理由&…

宁波网站建设托管17zwd一起做业网站

python 库windows安装 兵种:python程序员。 等级:二级。 攻击:较高。 防御:普通。 价格:低。 天赋:胶水,我方有c程序员时,速度可达到c程序员的80%。 天赋:成熟&…

服务好的常州网站建设无锡做网站公司哪家好电话

❤️作者主页:IT技术分享社区 ❤️作者简介:大家好,我是IT技术分享社区的博主,从事C#、Java开发九年,对数据库、C#、Java、前端、运维、电脑技巧等经验丰富。 ❤️个人荣誉: 数据库领域优质创作者🏆&#x…

网站怎么做抽奖wordpress个人

文章目录 前言正文什么是 MVVC什么是 MVVM什么是 SPA什么是SFC为什么 data 选项是一个函数Vue 组件通讯(传值)有哪些方式Vue 的生命周期方法有哪些如何理解 Vue 的单项数据流如何理解 Vue 的双向数据绑定Vue3的响应式原理是什么介绍一下 Vue 的虚拟 DOM介…

贵州铁路建设网站个人做网站模版是否有人买

目录 题目描述:答案:考点:代码实现: 题目描述: 哈沙德数是指在某个固定的进位制当中,可以被各位数字之和整除的正整数。 例如126是十进制下的一个哈沙德数,因为(126)1o mod (1+2&…

广州网站建设很棒 乐云践新国家建设部建筑业网站

优学院《土地资源学》答案在线查题2020高校邦《Java核心开发技术【实境编程】》章测试答案更多相关问题[问答题] 老区的汽油分馏塔(DA-101)原设计结构如何?[问答题] SRT-I型炉与SRT-I改进型炉(乙烷炉)的烧焦过程有何不同&#xff…

做网站工作职责电子商务主要学什么就业前景好不好

随着科技的发展,系统工程的设计体量逐渐庞大起来,尤其是对于轨道交通、航空航天、核电站等安全关键领域中,如何在复杂度逐年变大的同时保证其安全性和可靠性,是近年来各大公司需要研究的课题。最近比较火热的基于模型的系统工程&a…

网站搭建玩要多长时间wordpress博客程序文章自动更新

变参数函数 变参数函数是接收可变数量参数的函数(例如 std::printf )。 为声明变参数函数,要以省略号为最后的形参,例如 int printf(const char* format, ...); 。语法上的额外细节、自动参数转换及替用项见变参数。 为从函数…

php网站哪些电子商务网站建设实训

题目 天梯图书阅览室请你编写一个简单的图书借阅统计程序。当读者借书时,管理员输入书号并按下S键,程序开始计时;当读者还书时,管理员输入书号并按下E键,程序结束计时。书号为不超过1000的正整数。当管理员将0作为书号…

中国商标注册网查询网官网江苏网站seo营销模板

FreeSql 支持 CodeFirst 迁移结构至数据库,这应该是(O/RM)必须标配的一个功能。 与其他(O/RM)不同FreeSql支持更多的数据库特性,而不只是支持基础的数据类型,这既是优点也是缺点,优点是充分利用数据库特性辅助开发,缺点…

广元 网站建设十堰网络科技公司排名

learn from 从0开始学大数据&#xff08;极客时间&#xff09; MapReduce 编程模型 包含 Map 和 Reduce 两个过程 map 的主要输入是一对 <Key, Value> 值&#xff0c;输出一对 <Key, Value> 值将相同 Key 合并&#xff0c;形成 <Key, Value 集合 >再将这个…