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

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;

使用组件

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

效果

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值