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%;
}
`;

效果

相关推荐
90后小陈老师16 分钟前
3D个人简历网站 5.天空、鸟、飞机
前端·javascript·3d
chenbin___17 分钟前
react native text 显示 三行 超出部分 中间使用省略号
javascript·react native·react.js
漫路在线4 小时前
JS逆向-某易云音乐下载器
开发语言·javascript·爬虫·python
不爱吃糖的程序媛4 小时前
浅谈前端架构设计与工程化
前端·前端架构设计
BillKu5 小时前
Vue3 Element Plus 对话框加载实现
javascript·vue.js·elementui
郝YH是人间理想6 小时前
系统架构设计师案例分析题——web篇
前端·软件工程
Evaporator Core6 小时前
深入探索:Core Web Vitals 进阶优化与新兴指标
前端·windows
初遇你时动了情6 小时前
html js 原生实现web组件、web公共组件、template模版插槽
前端·javascript·html
QQ2740287567 小时前
Soundness Gitpod 部署教程
linux·运维·服务器·前端·chrome·web3
前端小崔7 小时前
从零开始学习three.js(18):一文详解three.js中的着色器Shader
前端·javascript·学习·3d·webgl·数据可视化·着色器