react实现一个搜索部门(input + tree)

目录

react实现一个搜索部门(input + tree)

searchDept.jsx

js 复制代码
import React, { useState, useEffect } from "react";
import StyleDeptId from "styled-components";
import SplitPane from 'react-split-pane';
import "./dept.scss";
import SearchDept from "./searchDept"
export default function Dept(props) {
  useEffect(() => {
    // init();
  }, []);

  return (
    <DeptWrap className="wrap">
      <SplitPane split="vertical" minSize={200} defaultSize={200}>
        <div className="left">
          <SearchDept></SearchDept>
        </div>
        <div className="right">right</div>
      </SplitPane>
    </DeptWrap>
  );
}

const DeptWrap = StyleDeptId.div`
display: flex;
height: 100%;
background: #ccc;
position: relative;
.left {
  background: pink;
  height: 100%;
}
.right {
  background: orange;
  height: 100%;
}
`;

treeData.js

js 复制代码
const treeData = [
  {
    id: '1',
    title: 'Parent1',
    children: [
      {
        id: '1-1',
        title: 'Child1-1',
      },
      {
        id: '1-2',
        title: 'Child1-2',
      },
      {
        id: '1-3',
        title: 'Child1-3',
        children: [
          {
            id: '1-3-1',
            title: 'Grandchild1-3-1',
          },
          {
            id: '1-3-2',
            title: 'Grandchild1-3-2',
          },
        ],
      },
    ],
  },
  {
    id: '2',
    title: 'Parent2',
    children: [
      {
        id: '2-1',
        title: 'Child2-1',
      },
      {
        id: '2-2',
        title: 'Child2-2',
      },
      {
        id: '2-3',
        title: 'Child1-2-3',
      },
    ],
  },
  {
    id: '3',
    title: 'Parent3',
    children: [
      {
        id: '3-1',
        title: 'Child3-1',
      },
      {
        id: '3-2',
        title: 'Child3-2',
      },
      {
        id: '3-3',
        title: 'Child3-3',
      },
    ],
  },
];

export default treeData;

使用组件

js 复制代码
import React, { useState, useEffect } from "react";
import StyleDeptId from "styled-components";
import SplitPane from 'react-split-pane';
import { RoleList, delRoleList } from "@/api/roleApi";
import SearchDept from "./searchDept"
export default function Dept(props) {

  const [loading, setLoading] = useState(false);
  useEffect(() => {
    // init();
  }, []);
  
  return (
    <DeptWrap className="wrap">
      {/* <Spin
        spinning={loading}
        style={{
          width: '100%',
          height: "100%",
        }}
      ></Spin> */}
      <SplitPane split="vertical" minSize={200} defaultSize={200}>
        <div className="left">
          <SearchDept></SearchDept>
        </div>
        <div className="right">right</div>
      </SplitPane>
    </DeptWrap>
  );
}

const DeptWrap = StyleDeptId.div`
display: flex;
height: 100%;
background: #ccc;
position: relative;
.left {
  background: pink;
  height: 100%;
}
.right {
  background: orange;
  height: 100%;
}
`;

效果

相关推荐
invicinble5 分钟前
把握理解技术文章转化为工程水平的深度理解
前端
前端炒粉9 分钟前
fetch+readablestream(Streamable)流式输出
java·服务器·前端
风骏时光牛马13 分钟前
AIRAG服务异常监控告警
前端
大厂码农老A17 分钟前
汤森路透的座上宾?Qwen3.5-397B-A17B到底有什么本事?
前端·人工智能·后端
静开25 分钟前
Skills和MCP 到底什么区别
前端·人工智能
伯远医学30 分钟前
RIP-seq 高分文献案例分享
java·前端·javascript·人工智能·算法·eclipse·html
hunterandroid31 分钟前
[鸿蒙从零到一] LazyForEach 复用陷阱与 KeyGenerator 设计实战
前端
Hilaku37 分钟前
Web Components 为什么火不起来?
前端·javascript·程序员
Liora_Yvonne42 分钟前
从数据库到 Vue 页面:用 LY Fullstack 完成第一个真实全栈业务模块
前端·后端·nestjs
hunterandroid1 小时前
自定义 View 绘制与触摸冲突:从滑动卡顿到事件分发闭环
android·前端