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


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

    searchDept.jsx

    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%;
    }
    `;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36

    treeData.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;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68

    使用组件

    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">
          {/* {
              width: '100%',
              height: "100%",
            }}
          > */}
          <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%;
    }
    `;
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46

    效果

    在这里插入图片描述

  • 相关阅读:
    如何驾驭逻辑、形式逻辑与AI算法?
    PackagesNotFoundError:学习利用报错信息找到解决方法
    wpf工程中加入Hardcodet.NotifyIcon.Wpf生成托盘
    Coursera Algorithm Ⅱ week2 Seam
    【追求卓越01】数据结构--数组
    字节面经总结
    AtCoder Beginner Contest 241EX(推式子)
    HTML超文本链接语言简介
    训练深度学习神经网络的常用5个损失函数
    webgl未使用独立显卡报告
  • 原文地址:https://blog.csdn.net/weixin_43845137/article/details/132788617