1.1.1 • Published 5 years ago

r-org-tree v1.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

介绍

react的组织树组件

使用方式

import React, { useState } from 'react'
import { OrgTree } from 'r-org-tree'
import { DataProps } from 'r-org-tree/es/components/OrgTree'

const horizontal = false; // true:横向  false:纵向
const collapsable = false; // true:可折叠 false:不可折叠 
const expandAll = true; // true: 全部展开 false:全部折叠 

interface DemoProps {
	// 自己添加
}

const Demo: React.FC<DemoProps> = ({

}) => {
	const [value, setValue] = useState()

	const data: DataProps = {
		id: 0,
		label: '一级',
		children: [
			{
				id: 1,
				label: <div>二级内容1</div>,
				conditionList: '条件项',
				children: [
					{
						id: 4,
						label: '三级内容1',
						conditionList: '年后111',
					},
					{
						id: 5,
						label: '三级内容2'
					}
				]
			},
			{
				id: 2,
				label: <div>二级内容1</div>,
				children: [{ id: 44, label: 'demo' }]
			}
		]
	}

	const handleClick = (_e, data) => {
		console.log('data', data)
	}

	return (
		<OrgTree
			data={data}
			activeId={value}
			horizontal={horizontal}
			collapsable={collapsable}
			expandAll={expandAll}
			onClick={handleClick}
		/>
	)
}

属性

参数说明类型默认值是否必填
data数据源json-
labelWidthlabel项宽度string | number-
horizontal是否水平booleanfalse
collapsable是否可折叠booleanfalse
expandAll是否全部展开booleanfalse
activeId选中的idstring | number-
nodedata中的 id label expand children的字段,可以将数据源的字段进行替换object{id: 'id',label: 'label',expand: 'expand',children: 'children'}
labelClassNamelabel自定义类名string-
conditionClassNameconditionList自定义类名string-
onClick点击label函数(e: React.MouseEventHandler, data: any) => void-
onConditionClick点击conditionList时触发函数(e: React.MouseEventHandler, data: any) => void-
renderContent处理label的数据,渲染label函数(data: any) => void-
1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago