UNPKG

cjd-parkball

Version:

> 中后台业务组件库,中后台就像公园,进入需要买门票(登录),所以以 Parkball(公园球) 命名,公园内必定捕获!作为一个组件库,提供使用方法文档,方便开发者的调用

64 lines (53 loc) 1.13 kB
--- category: 2 title: 从数据直接生成 title_en: Generate from tree data --- zh-CN 使用 `treeData`JSON 数据直接生成树结构。 en-US The tree structure can be populated using `treeData` property. This is a quick and easy way to provide the tree content. ````jsx import { TreeSelect } from 'parkball'; const treeData = [{ title: 'Node1', value: '0-0', key: '0-0', children: [{ title: 'Child Node1', value: '0-0-1', key: '0-0-1', }, { title: 'Child Node2', value: '0-0-2', key: '0-0-2', }], }, { title: 'Node2', value: '0-1', key: '0-1', }]; class Demo extends React.Component { state = { value: undefined, } onChange = (value) => { console.log(value); this.setState({ value }); } render() { return ( <TreeSelect style={{ width: 300 }} value={this.state.value} dropdownStyle={{ maxHeight: 400, overflow: 'auto' }} treeData={treeData} placeholder="Please select" treeDefaultExpandAll onChange={this.onChange} /> ); } } ReactDOM.render(<Demo />, mountNode); ````