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

目录

  • react实现一个搜索部门(input + tree)
    • searchDept.jsx
    • treeData.js
    • 使用组件
    • 效果

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

效果

在这里插入图片描述文章来源地址https://uudwc.com/A/Y6wGM

原文地址:https://blog.csdn.net/weixin_43845137/article/details/132788617

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请联系站长进行投诉反馈,一经查实,立即删除!

h
上一篇 2023年09月18日 04:11
K8S:Yaml文件详解
下一篇 2023年09月18日 04:11