-
Notifications
You must be signed in to change notification settings - Fork 202
Expand file tree
/
Copy pathdisable.js
More file actions
85 lines (78 loc) · 1.58 KB
/
disable.js
File metadata and controls
85 lines (78 loc) · 1.58 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* eslint react/no-multi-comp:0, no-console:0 */
import 'rc-tree-select/assets/index.less';
import TreeSelect from 'rc-tree-select';
import React from 'react';
const SHOW_PARENT = TreeSelect.SHOW_PARENT;
const treeData = [
{
label: 'Node1',
value: '0-0',
key: '0-0',
children: [
{
label: 'Child Node1',
value: '0-0-0',
key: '0-0-0',
},
],
},
{
label: 'Node2',
value: '0-1',
key: '0-1',
children: [
{
label: 'Child Node3',
value: '0-1-0',
key: '0-1-0',
},
{
label: 'Child Node4',
value: '0-1-1',
key: '0-1-1',
},
{
label: 'Child Node5',
value: '0-1-2',
key: '0-1-2',
},
],
},
];
class Demo extends React.Component {
state = {
value: ['0-0-0'],
disabled: false,
};
onChange = (value, ...args) => {
console.log('onChange ', value, args);
this.setState({ value });
};
switch = checked => {
this.setState({ disabled: checked });
};
render() {
const { disabled, value } = this.state;
const tProps = {
treeData,
disabled,
value,
onChange: this.onChange,
multiple: true,
allowClear: true,
treeCheckable: true,
showCheckedStrategy: SHOW_PARENT,
searchPlaceholder: 'Please select',
style: {
width: 300,
},
};
return (
<div>
<TreeSelect {...tProps} />
<input type="checkbox" onChange={e => this.switch(e.target.checked)} /> 禁用
</div>
);
}
}
export default () => <Demo />;